Re: How to do Chebyshev expansion in Mathematica?
- To: mathgroup at smc.vnet.net
- Subject: [mg68467] Re: [mg68433] How to do Chebyshev expansion in Mathematica?
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Sun, 6 Aug 2006 02:56:53 -0400 (EDT)
- Reply-to: hanlonr at cox.net
- Sender: owner-wri-mathgroup at wolfram.com
Needs["Graphics`"]; http://mathworld.wolfram.com/ChebyshevApproximationFormula.html Clear[ChebyshevApprox]; ChebyshevApprox[n_Integer?Positive, f_Function, x_]:= Module[{c,xk}, xk=Pi(Range[n]-1/2)/n; c[j_]= 2*Total[Cos[j*xk]*(f/@Cos[xk])]/n; Total[Table[c[k]*ChebyshevT[k, x],{k,0,n-1}]]-c[0]/2]; f = 3*#^2*Exp[-2*#]*Sin[2#*Pi]&; ChebyshevApprox[3,f,x]//Simplify ((-(3/4))*((-E^(2*Sqrt[3]))*(Sqrt[3] - 2*x) - 2*x - Sqrt[3])*x*Sin[Sqrt[3]*Pi])/E^Sqrt[3] DisplayTogetherArray[ Partition[ Table[ Plot[{f[x],ChebyshevApprox[n,f,x]},{x,-1,1}, Frame->True, Axes->False, PlotStyle->{Blue,Red}, PlotRange->{-2,10}, Epilog\[Rule]Text["n = " <> ToString[n], {0.25,5}]], {n,9}], 3], ImageSize->500]; Bob Hanlon ---- Michael <michael.monkey.in.the.jungle at gmail.com> wrote: > anybody please give me some pointers? Thanks a lot! > >