# Math Help - Approximation of function

1. ## 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!

2. 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 $f(x)$ should be:

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

CB

3. Sorry, w2 should be (rt 6)x / 2. That should be orthonormal, right?

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

CB

5. 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 $w_1$ and $w_3$ are even functions (and we are working with the interval $[-1,1]$ and the usual inner product) that their coefficients in the expansion of $\sin(\pi x)$ will be zero. So your approximation will be:

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

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

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

CB

6. Ah, I see what you mean, thanks for clearing all that up!