Re: Orthonormalization of function space
- From: David C. Ullrich <dullrich@xxxxxxxxxxx>
- Date: Mon, 21 Apr 2008 07:28:25 -0500
On Sun, 20 Apr 2008 12:50:27 +0000, Daniel Kraft <d@xxxxxxxx> wrote:
Hi,
I'm looking at the vector space of functions mapping [-Pi, Pi] to the
reals over the reals, given the inner product:
<f, g> = Integral(x from -Pi to Pi, f(x)*g(x)*dx)
There [1, x, x^2, x^3] is a four-dimensional subspace, and I've
orthonormalized this basis numerically to:
0.399
0.220*x
-0.446+0.136*x^2
-0.504*x^2+0.085*x^3
Using my inner product routines and after some other checks, this seems
to be really an orthonormal quadrupel spanning this subspace.
Then I did project sin(x) orthogonally into this subspace, getting
1.382*x-1.097*x^3 as component parallel to it.
While this polynomial looks a bit like sin(x), it is an approximation
not even close to the quality of the third-order taylor polynomial
(x+1/6*x^3 IIRC).
Well, once you get the numbers straight: That orthogonal projection
gives the best approximation _in_ the space L^2(-pi, pi); if you
prefer that means that it minimizes the root-mean-square error.
Regardless of what it looks like it _is_ a better approximation
_in that sense_ than the Taylor polynomial.
Ok, now you got me thinking. Let's see, the best approximation
is going to be odd, hence Ax + Bx^3. We should have
int_{-pi}^pi (Ax + Bx^3 - sin x) x dx = 0,
int_{-pi}^pi (Ax + Bx^3 - sin x) x^3 dx = 0.
If I did the calculus and algebra right that says
A = 315*(pi^(-4))/2 - 15*(pi^(-2))/2 = 0.856983327795
B = 35*(pi^(-4))/2 - 525*(pi^(-6))/2 = -0.0933876972832.
So. Define S(x) = Ax + Bx^3 with A and B as above.
Define T(x) = x - x^3/6.
Now numerically evaluate the two errors
(1/2pi) )int_{-pi}^pi |P(x) - sin(x)|^2
with P = S and P = T and let us know the result.
Aargh, again I can't wait. Using awesomely crude
numerical integration I get an (squared) error of
0.004 for S and 1.118 for T; S is a _much_ better
approximation (in _this_ measure of the error).
Heh-heh: In fact the fact that I got such a small RMS
error for S convinces me I must have done the calculus
and the algebra correctly...
B = 35*(pi**(-4))/2 - 525*(pi**(-6))/2
A = 315*(pi**(-4))/2 - 15*(pi**(-2))/2
def avg(f,N):
sum = 0
for j in range(N):
sum = sum + f(j*pi/N)
return sum/N
def S(x):
return abs(sin(x) - (A*x+B*x**3))**2
def T(x):
return abs(sin(x) - x + x/6.0)**2
print avg(S,10000)
print avg(T,10000)
Is this ok for the kind of thing I've done, or should it really
approximate sin(x) better? I'm just unsure if I did/programmed
something wrong, although I can't find any mistakes. Has anyone
experiences with things like this?
Thanks a lot,
Daniel
David C. Ullrich
.
- Follow-Ups:
- Re: Orthonormalization of function space
- From: David C . Ullrich
- Re: Orthonormalization of function space
- References:
- Orthonormalization of function space
- From: Daniel Kraft
- Orthonormalization of function space
- Prev by Date: Basic rules for corporate branding/embroidery and printing.
- Next by Date: Re: Uniform convergence of Fourier series
- Previous by thread: Re: Orthonormalization of function space
- Next by thread: Re: Orthonormalization of function space
- Index(es):
Relevant Pages
|
Loading