Cal

Author

Eric W. Weisstein
August 18, 2002

This notebook downloaded from http://mathworld.wolfram.com/notebooks/SpecialFunctions/Cal.nb.

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

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

Initialization

<<Graphics`Colors`;

Code

WalshOnes[s_,k_]:=With[{f=Identity,g=Reverse},
Nest[Apply[Join,f[{Map[Flatten[Map[{#,#}&,#]]&,#],Map[Flatten[Map[{#,-#}&,#]]&,g[#]]}]]&,{{1}},s]
][[k]]

Walsh[{n_,k_},y_]:=Module[{x=Mod[y,2^n]},
2Plus@@Flatten[MapIndexed[(-1)^(#2-1) UnitStep[x-#1]&,Drop[FoldList[Plus,0,Length/@Split[WalshOnes[n,k]]],-1]
]]-1
]

CalPlot[n_,p_:4,opts___]:=Module[{k,x,dx=.1,dy=.1,l=2^n},
Partition[
Table[
Plot[Evaluate[Walsh[{n,k},x]],{x,-dx,l+dx},
opts,
PlotStyle->Red,
PlotRange->{Automatic,{-1-dy,1+dy}},
Ticks->{Range[0,l],{-1,0,1}},
PlotLabel->TraditionalForm[Cal[n,(k-1)/2]],
DisplayFunction->Identity],
{k,1,l,2}],
p,p,{1,1},{}]
]

Plots

Show[GraphicsArray[Flatten[
Table[CalPlot[n],{n,3}],1]]]

Definitions

Cal[n_,k_]:=WalshOnes[n,2k+1]
Cal[{n_,k_},x_]:=Walsh[{n,2k+1},x]

Sal[n_,k_]:=WalshOnes[n,2k]
Sal[{n_,k_},x_]:=Walsh[{n,2k},x]