MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

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! 
> 
> 


  • Prev by Date: Re: returning a variable's name, rather than the variable's contents
  • Next by Date: Re: near Planck's mass
  • Previous by thread: Eigensystem[] for higher dimensions?
  • Next by thread: critical points of a third order polynomial fit (simplification)