Re: Orthonormalization of function space



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
.



Relevant Pages

  • Orthonormalization of function space
    ... I'm looking at the vector space of functions mapping to the reals over the reals, given the inner product: ... Using my inner product routines and after some other checks, this seems to be really an orthonormal quadrupel spanning this subspace. ... While this polynomial looks a bit like sin, it is an approximation not even close to the quality of the third-order taylor polynomial. ...
    (sci.math)
  • Re: Orthonormalization of function space
    ... reals over the reals, given the inner product: ... Using my inner product routines and after some other checks, ... While this polynomial looks a bit like sin, it is an approximation ... def avg: ...
    (sci.math)
  • Re: Comparing two notions of computable number
    ... perhaps there is a little confusion in your the original definition. ... the approximation or the real r or not. ... the halting probability of a University Turing Machine (or you call ... formulations of the recursive reals. ...
    (comp.theory)
  • Re: Kind of NOT integer constant
    ... > I believe that is the definition of "addition" for reals, ... > result of any operation giving a real includes an approximation. ... computational result could differ from the mathematical one. ... Is the compiler that uses extra precision for arithmetic ...
    (comp.lang.fortran)
  • Re: Comparing two notions of computable number
    ... formulations of the recursive reals. ... 1) a real number a is computable iff there exists a Turing machine ... which for given rational number eps produces a rational approximation ...
    (comp.theory)

Loading