Haar Wavelets > # the Haar scaling function phi(x) > phi := x -> piecewise( 0 < x and x <= 1, 1 ); > > plot(phi(x), x=-1..2 ); > phi := x -> piecewise(0 < x and x <= 1, 1) > # phi(t) = phi(2*t) + phi(2*t-1) > plot( t -> phi(2*t) + phi(2*t-1), -1..2 ); > > > phi_ := (i,j) -> subs(I=i,J=j, x -> 2^(J/2) * phi( 2^J * x - I ) ); > (1/2 J) J phi_ := (i, j) -> subs(I = i, J = j, x -> 2 phi(2 x - I)) > plot( {phi_(i,1)(x) $ i=0..1}, x=-1..2 ); > > plot( x -> phi_(0,1)(x) + phi_(1,1)(x), -1..2 ); > plot( {phi_(i,2) $ i=0..3}, -1..2 ); > > > innerproduct := (f,g) -> int( f(x) * g(x), x=0..1 ); > 1 / | innerproduct := (f, g) -> | f(x) g(x) dx | / 0 > innerproduct( phi_(0,2), phi_(0,2) ); > innerproduct( phi_(0,2), phi_(1,2) ); > innerproduct( phi_(0,2), phi_(2,2) ); > innerproduct( phi_(0,2), phi_(3,2) ); > 1 0 0 0 > f := 3*phi_(0,2) + 1*phi_(1,2) + 2*phi_(2,2) + 1*phi_(3,2); > > innerproduct( f, phi_(0,2) ); > innerproduct( f, phi_(1,2) ); > innerproduct( f, phi_(2,2) ); > innerproduct( f, phi_(3,2) ); > > f := 3 (x -> 2 phi(4 x)) + (x -> 2 phi(4 x - 1)) + 2 (x -> 2 phi(4 x - 2)) + (x -> 2 phi(4 x - 3)) 3 1 2 1 > # The Haar wavelets > Haar_Psi := x -> piecewise( 0 < x and x <= 1/2, 1, 1/2 < x and x <= 1, -1 ); Haar_Psi := x -> piecewise(0 < x and x <= 1/2, 1, 1/2 < x and x <= 1, -1) > plot(Haar_Psi(x), x=-1..2 ); > # Haar_Psi(t) = phi(2*t) - phi(2*t-1) > > plot( t -> phi(2*t) - phi(2*t-1), -1..2 ); > Psi_ := (i,j) -> subs(I=i,J=j, x -> 2^(J/2) * Haar_Psi( 2^J * x - I ) ); Psi_ := (i, j) -> (1/2 J) J subs(I = i, J = j, x -> 2 Haar_Psi(2 x - I)) > plot( {Psi_(i,2)(x) $ i=0..3}, x=-1..2 ); > # Psi(t) = phi(2*t) - phi(2*t-1) > > plot( t -> phi(2*t) - phi(2*t-1), -1..2 ); > g := 5*Psi_(0,2) + 2*Psi_(1,2) - 3*Psi_(2,2) + 1*Psi_(3,2); g := 5 (x -> 2 Haar_Psi(4 x)) + 2 (x -> 2 Haar_Psi(4 x - 1)) - 3 (x -> 2 Haar_Psi(4 x - 2)) + (x -> 2 Haar_Psi(4 x - 3)) > plot( g, 0..1 ); > innerproduct := (f,g) -> int( f(x) * g(x), x=0..1 ); > 1 / | innerproduct := (f, g) -> | f(x) g(x) dx | / 0 > innerproduct( g, Psi_(0,2) ); 5 > innerproduct( g, Psi_(1,2) ); 2 > innerproduct( g, Psi_(2,2) ); -3 > innerproduct( g, Psi_(3,2) ); 1 > innerproduct( f, Psi_(0,1) ); > innerproduct( f, Psi_(1,1) ); 1/2 2 1/2 1/2 2 > innerproduct( f, Psi_(0,0) ); 1/2 >