Group Abstract Group Abstract

Message Boards Message Boards

[GIF] Bessel (Taylor approximations to a Bessel function)

Taylor approximations to a Bessel function

Bessel

This animation shows successive Taylor polynomial approximations to the Bessel function of the first kins $J_0$. Specifically, the Taylor series for $J_0$ is

$J_0(x) = \sum_{n=0}^\infty \frac{(-1)^n}{4^n (n!)^2} x^{2n}$,

and this animations shows the first 51 partial sums.

Here's the code:

With[{cols = RGBColor /@ {"#28CC9E", "#132F2B"}},
 Manipulate[
  Plot[
   Evaluate@Table[Sum[(-1)^n/(4^n (n!)^2) x^(2 n), {n, 0, k}], {k, 0,  m}], {x, -30, 30},
   PlotRange -> {{-29.9, 29.9}, {-1.2, 1.2}}, 
   Background -> cols[[-1]], 
   PlotStyle ->  Directive[CapForm[None], cols[[1]], Opacity[.35], Thickness[.003]],
   Axes -> False, ImageSize -> 600], 
   {m, -1, 50, 1}]
 ]

(Incidentally, the CapForm[None] bit in the code is due to what seems to be an implementation bug in Plot: the graph of a function in Plot seems to be built out of several concatenated curves using the default CapForm option, but when PlotStyle includes Opacity[a] for some $a<1$, the concatenated curves have an overlap which shows up as a bright spot unless you include CapForm[None] in PlotStyle.)

6 Replies
Posted 9 years ago

The Padé approximants are interesting to look at as well:

With[{cols = RGBColor /@ {"#28CC9E", "#132F2B"}}, 
     Manipulate[Plot[Evaluate @ Table[PadeApproximant[BesselJ[0, x], {x, 0, k}], {k, 0, m, 2}],
                     {x, -30, 30}, Axes -> False,  Background -> cols[[-1]], ImageSize -> 600,
                     PlotRange -> {{-29.9, 29.9}, {-1.2, 1.2}}, 
                     PlotStyle -> Directive[CapForm[None], cols[[1]], Opacity[.35], Thickness[.003]]],
                {m, 0, 50, 2}]]

Padé approximants of zero-order Bessel function

POSTED BY: J. M.
POSTED BY: EDITORIAL BOARD
Posted 9 years ago
POSTED BY: Brad Klee

Just a note that a general term can be obtained as

SeriesCoefficient[BesselJ[0, z], {z, 0, n}]

enter image description here

and simplified further

FullSimplify[SeriesCoefficient[BesselJ[0, z], {z, 0, n}]]

enter image description here

POSTED BY: Vitaliy Kaurov

Indeed, although my preference would be to increase the order in Series by 2 to avoid repeats. Like so:

With[{cols = RGBColor /@ {"#28CC9E", "#132F2B"}}, 
 Manipulate[
  Plot[Evaluate@
    Table[Normal@Series[BesselJ[0, x], {x, 0, 2 n}], {n, 0, m}], {x, -30, 30},
   PlotRange -> {{-29.9, 29.9}, {-1.2, 1.2}}, Background -> cols[[-1]], 
   PlotStyle -> Directive[CapForm[None], cols[[1]], Opacity[.35], Thickness[.003]], 
   Axes -> False, ImageSize -> 600],
  {m, -1, 50, 1}]]

You can do something similar with Series, but it doesn't run as fast.

With[{cols = RGBColor /@ {"#28CC9E", "#132F2B"}},
 Manipulate[
  Plot[
   Evaluate@Table[Normal@Series[BesselJ[0,x],{x,0,n}],{n,0,m}], {x, -30, 30},
   PlotRange -> {{-29.9, 29.9}, {-1.2, 1.2}}, 
   Background -> cols[[-1]], 
   PlotStyle ->  Directive[CapForm[None], cols[[1]], Opacity[.35], Thickness[.003]],
   Axes -> False, ImageSize -> 600], 
   {m, -1, 50, 1}]
 ]

(I like the plot styling a lot by the way!)

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard