1
$\begingroup$

As the subject title to the post suggests, I am trying to plot a Bessel function on Mathematica. The plot I am trying to create for can be seen below.

$\frac{d(J_m (x))}{dx}$ for $m=0,1,2,3,4$ and $0 \leq x \leq10$

To plot for the above Bessel function, please refer to the below code I wrote as my attempt at plotting the Bessel function.

f[x_]:=BesselJ[m,x],{m,1,4}

Plot[f'[x],{x,0,10}]

However, Mathematica just gives me syntax error protesting that my BesselJ function needs more input. The error aside, though, I am also having a bit of trouble finding ways to plot the 5 Bessel function lines (for the different $m$'s).

Thank you for reading through the post and any help toward resolving my question would be greatly appreciated!

$\endgroup$
2
  • $\begingroup$ @Bill , thank you for the help! As a bit something extra, I wanted to label my given plot so I can immediately identify which line corresponds to which value for $m$. I did try writing the code Plot[f'[x],{x,0,10},PlotLabels->{"m=0","m=1","m=2","m=3","m=4"}] , but that only labeled $m=0$ while the other lines did not get labeled at all. I did also try Plot[f'[x],{x,0,10},PlotLabels->Placed[Automatic, Above]], but that did not work either. If possible, do you mind suggesting a good piece of code to help label all my Bessel function lines to its corresponding $m$ value? $\endgroup$ Commented Sep 17, 2020 at 20:37
  • 2
    $\begingroup$ Clear[f]; f[x_] = Table[BesselJ[m, x], {m, 0, 4}]; Plot[f'[x] // Evaluate, {x, 0, 10}, PlotLabels -> {"m=0", "m=1", "m=2", "m=3", "m=4"}] $\endgroup$ Commented Sep 18, 2020 at 0:01

1 Answer 1

2
$\begingroup$
labels = "m" <> ToString@# & /@ Range[0, 4]
pF = MapThread[
     Plot[Callout[BesselJ[#1, x] // Evaluate
         , #2
         , Above
         ] // Evaluate
       , {x, 0, 4 \[Pi]}
       , PlotRange -> {-1/Sqrt[2], 1}
       , PlotRangePadding -> Scaled[.05]
       , ImageSize -> 400
       , PlotStyle -> ColorData[97, #1]
       , Ticks -> {Range[0, 4 \[Pi], \[Pi]/2], Automatic}
       , PlotLabel -> "Bessel functions"
       ] &,
     {
      Range[0, 4]
      , labels
      }
     ] // Show;

pD = MapThread[
    Plot[Callout[D[BesselJ[#1, x] // Evaluate, x]
        , #2
        , Above
        ] // Evaluate
      , {x, 0, 4 \[Pi]}
      , PlotRange -> {-1/Sqrt[2], 1}
      , PlotRangePadding -> Scaled[.05]
      , ImageSize -> 400
      , PlotStyle -> ColorData[97, #1]
      , Ticks -> {Range[0, 4 \[Pi], \[Pi]/2], Automatic}
      , PlotLabel -> "Derivatives of Bessel functions"
      ] &,
    {
     Range[0, 4]
     , labels
     }
    ] // Show;

Grid[{{pF, pD}}]

Bessel functions and their derivatives

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.