Haar Function

Author

Eric W. Weisstein
September 22, 2004

This notebook downloaded from http://mathworld.wolfram.com/notebooks/Wavelets/HaarFunction.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/HaarFunction.html.

For a list of Eric's math packages that may be needed to evaluate this notebook, see http://mathworld.wolfram.com/packages/.  An archive of these packages may be downloaded from http://mathworld.wolfram.com/packages/MathWorldPackages.zip, as well as from the Mathematica Information Center's MathSource item 4775.  A list of Eric's utility packages that may be needed to evaluate this notebook may be downloaded from MathSource item 5087.

©2005 Wolfram Research, Inc. except for portions noted otherwise

Code

Psi[x_]:=Piecewise[{{1,0≤x≤1/2},{-1,1/2≤x≤1}},0]
Psi[{j_,k_},x_]:=Psi[2^j x-k]

Plots

v5.0

Psi[x_]:=Which[x<0,0,x==0,1/2,x<1,1,x==1,1/2,x>1,0];
W[x_]:=Which[x<0,0,x==0,1/2,x>0&&x<1/2,1,x==1/2,0,x>1/2&&x<1,-1,x==1,-1/2,x>1,0]

HaarPlot[f_]:=Plot[f,{x,-.1,1.1},PlotRange->{{-.1,1.1},{-1.1,1.1}},Ticks->{{-1,0,1},{-1,0,1}},PlotStyle->Red]

Show[GraphicsArray[
Block[{$DisplayFunction=Identity},
{{HaarPlot[Psi[x]],HaarPlot[W[x]],HaarPlot[W[2x]],HaarPlot[W[2x-1]]},{HaarPlot[W[4x]],HaarPlot[W[4x-1]],HaarPlot[W[4x-2]],HaarPlot[W[4x-3]]}}],ImageSize->800
]]

Show[GraphicsArray[{{1,Sin[x],Cos[x],Sin[2x]},{Cos[2x],Sin[3x],Cos[3x],Sin[4x]}}]

GraphicsArray[Partition[Table[Plot[z,{x,-π,π},PlotStyle->Blue],{z,{1,Sin[x],Cos[x],Sin[2x],Cos[2x],Sin[3x],Cos[3x],Sin[4x]}}],4],ImageSize->800]

v5.1

Psi[x_]:=Piecewise[{{1,0≤x≤1/2},{-1,1/2≤x≤1}},0]
Psi[{j_,k_},x_]:=Psi[2^j x-k]

HaarPlot[i_,x_]:=Module[{},
Plot[Evaluate[Psi[i,x]],
{x,-.1,1.1},
PlotRange->{{-.1,1.1},{-1.1,1.1}},
Ticks->{{-1,0,1},{-1,0,1}},PlotStyle->Red,
PlotLabel->TraditionalForm[Subscript[ψ,Sequence@@i]==ψ[2^i[[1]]x-i[[2]]]]
]
]

Show[GraphicsArray[Block[{$DisplayFunction=Identity},
Map[HaarPlot[#,x]&,Table[{j,k},{j,0,2},{k,0,2^j-1}],{2}]
]
],ImageSize->500
]

Orthogonality

Table[Integrate[Psi[x]Psi[{j,k},x],{x,0,1}],{j,0,4},{k,0,2^j-1}]

Integrate[Psi[#1,x]Psi[#2,x],{x,0,1}]&@@@Select[Flatten[Table[{{j,k},{l,m}},{j,0,2},{k,0,2^j-1},{l,0,2},{m,0,2^l-1}],3],Unequal@@#&]

Integrate[Psi[x]Psi[{j,k},x],{x,0,1},Assumptions->(j|k)∈Integers&&0≤k≤(2^j)-1]