Approximation of function

• Apr 3rd 2009, 08:46 PM
h2osprey
Approximation of function
An inner product <f,g> is defined as the integral from -1 to 1 of f(x)g(x).

Given an orthonormal basis for the set of polynomials of degree less than or equal to 2, i.e.,

w1 = (rt 2)/2,
w2 = (rt 6)/2,
w3 = [(x^2 - 1/3) 3(rt10)] / 4,

Find the polynomial of degree at most two which is closest to sin (pi x).

I tried to minimize the norm of v - a linear combination of w1, w2 and w2, and I arrived at the answer 3/pi, which seems wrong. I checked my answer using an approximation through taylor series and as expected I obtained pi.

I can't figure out where I went wrong - all the integration seems to be correct; any help would be much appreciated. Thanks!
• Apr 3rd 2009, 09:31 PM
CaptainBlack
Quote:

Originally Posted by h2osprey
An inner product <f,g> is defined as the integral from -1 to 1 of f(x)g(x).

Given an orthonormal basis for the set of polynomials of degree less than or equal to 2, i.e.,

w1 = (rt 2)/2,
w2 = (rt 6)/2,
w3 = [(x^2 - 1/3) 3(rt10)] / 4,

Find the polynomial of degree at most two which is closest to sin (pi x).

I tried to minimize the norm of v - a linear combination of w1, w2 and w2, and I arrived at the answer 3/pi, which seems wrong. I checked my answer using an approximation through taylor series and as expected I obtained pi.

I can't figure out where I went wrong - all the integration seems to be correct; any help would be much appreciated. Thanks!

1. Check you basis, as what you have given is not an orthonormal basis for your desired space.

2. When you have the right basis your approximating polynomial for $\displaystyle f(x)$ should be:

$\displaystyle P(x)=\langle w1,f\rangle w_1(x) + \langle w2,f\rangle w_2(x) + \langle w3,f \rangle w_3(x)$

CB
• Apr 3rd 2009, 09:33 PM
h2osprey
Sorry, w2 should be (rt 6)x / 2. That should be orthonormal, right?
• Apr 3rd 2009, 09:54 PM
CaptainBlack
Quote:

Originally Posted by h2osprey
Sorry, w2 should be (rt 6)x / 2. That should be orthonormal, right?

Yes

CB
• Apr 3rd 2009, 10:34 PM
CaptainBlack
Quote:

Originally Posted by h2osprey
An inner product <f,g> is defined as the integral from -1 to 1 of f(x)g(x).

Given an orthonormal basis for the set of polynomials of degree less than or equal to 2, i.e.,

w1 = (rt 2)/2,
w2 = (rt 6)/2,
w3 = [(x^2 - 1/3) 3(rt10)] / 4,

Find the polynomial of degree at most two which is closest to sin (pi x).

I tried to minimize the norm of v - a linear combination of w1, w2 and w2, and I arrived at the answer 3/pi, which seems wrong. I checked my answer using an approximation through taylor series and as expected I obtained pi.

Taylor series are no guide here, the will give a best point approximation, this process will give you the best approximation on an interval with respect to the norm implied by the inner product.

What you can say without any computation is that as $\displaystyle w_1$ and $\displaystyle w_3$ are even functions (and we are working with the interval $\displaystyle [-1,1]$ and the usual inner product) that their coefficients in the expansion of $\displaystyle \sin(\pi x)$ will be zero. So your approximation will be:

$\displaystyle P(x)=\langle w_2,g \rangle w_2(x)$

where $\displaystyle g(x)=\sin(\pi x)$

The attachment shows a plot of the function and the fitted polynomial (line).

CB
• Apr 3rd 2009, 11:17 PM
h2osprey
Ah, I see what you mean, thanks for clearing all that up!