1
$\begingroup$

I was wondering why I was having difficulty plotting ∂[LegendreP[l, m, Cos[x]], x], where $l\in\mathbb{N}$ and $m\in\{-l,~-l+1,\cdots,l-1,~l\}$ as per usual for this function. I even tried the equivalent Subscript[∂, x]LegendreP[l, m, Cos[x]] (I am aware that doesn't come out neatly on this page, but that's what copying the code gives after pasting it).

Is it a variable type issue and if so, how can I get around this?

$\endgroup$
2
  • $\begingroup$ The principal difficulty seem to be correct syntax for the derivative: D[LegendreP[L0, m, Cos[x]], x] $\endgroup$
    – Michael E2
    Commented Jul 1, 2017 at 1:12
  • $\begingroup$ Use D[LegendreP[l, m, Cos[x]], x] not ∂[LegendreP[l, m, Cos[x]], x] The 1st form gives -(1/(-1 + Cos[x]^2))((-1 - l) Cos[x] LegendreP[l, m, Cos[x]] + (1 + l - m) LegendreP[1 + l, m, Cos[x]]) Sin[x] $\endgroup$
    – m_goldberg
    Commented Jul 1, 2017 at 1:48

1 Answer 1

2
$\begingroup$

You can set m to depend on L, something like this. But when L=0 there is a problem so need to check for it.

enter image description here

ClearAll[L0, m, x];
Manipulate[
 expr = D[LegendreP[L0, m, Cos[x]], x];
 If[L0 != 0,

  Plot[expr, {x, -L0, L0}, Frame -> True, ImageSize -> 400, 
   FrameLabel -> {{"f(x)", None}, {"x", "D[LegendreP[L0,m,Cos[x]],x]"}}, 
   ImagePadding -> 50, 
   GridLines -> Automatic, 
   GridLinesStyle -> LightGray, 
   PlotStyle -> Red],

  Plot[expr, {x, -1, 1}, Frame -> True, ImageSize -> 400, 
   FrameLabel -> {{"f(x)", None}, {"x", 
      "D[LegendreP[L0,m,Cos[x]],x]"}}, ImagePadding -> 50]
  ],

 {{L0, 1, "L"}, -10, 10, 1, ImageSize -> Small, Appearance -> "Labeled"},
 {{m, 1, "m"}, -L0, L0, 1, ImageSize -> Small, Appearance -> "Labeled"}
 ]
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.