3
$\begingroup$

I'm working with the following expressions:

$$\left(\frac{1-\tanh (X)}{\tanh (X)+1}\right)^{-k}=\pm\frac{P_2^{(k,-k)}(\tanh (X))}{P_2^{(-k,k)}(\tanh (X))}$$

where $X\in[0,5]$ and $k\in\left[-\sqrt{\frac{16}{3}},\sqrt{\frac{16}{3}}\right]$ exluding $k\in\mathbb{Z}$. I want to obtain an X vs. k plot, so I tried the following:

ContourPlot[{((1 - Tanh[X])/(1 + Tanh[X]))^-k == 
   JacobiP[2, k, -k, Tanh[X]]/JacobiP[2, -k, k, Tanh[X]],
  ((1 - Tanh[X])/(1 + Tanh[X]))^-k == -(JacobiP[2, k, -k, Tanh[X]]/
    JacobiP[2, -k, k, Tanh[X]])}, {X, 0, 5}, {k, -Sqrt[16/3], Sqrt[
  16/3]}, MaxRecursion -> 2, PlotPoints -> 100, 
 PlotRange -> {{0, 5}, Full}, FrameLabel -> Automatic, 
 ContourStyle -> {Red, Blue}, 
 PlotLegends -> Placed[{"+sign", "-sign"}, {0.8, 0.1}], 
 Exclusions -> 
  Flatten[{Table[k == n, {n, -4, 4, 1}], 
    JacobiP[2, -k, k, Tanh[X]] == 0}]]

And I got

enter image description here

But, since I'm reproducing a plot, I expect to obtain this

enter image description here

So, I dont know if ContourPlot can reach some sparse points to yield something like this

enter image description here

$\endgroup$
2
  • $\begingroup$ The sparse points which you are mentioning are included in the Exclusions if I am not mistaken; see what you get for Exclusions -> Flatten[{Table[k == n, {n, 0, 4, 1}], JacobiP[2, -k, k, Tanh[X]] == 0}] Am I confusing myself? $\endgroup$
    – bmf
    Jan 11, 2023 at 7:15
  • $\begingroup$ @bmf The 'Exclusions' part was added to avoid $k\in\mathbb{Z}$ and possible $P_2^{(-k,k)}(\tanh (X))=0$ points. It has a 'Table' because this plot is part of a series of plots, in this case $k$ cannot be equal to $-2,-1,0,1$ and 2. $\endgroup$ Jan 11, 2023 at 7:21

1 Answer 1

5
$\begingroup$

You can split the plots and separately specify exclusions:

g1 = ContourPlot[{((1 - Tanh[X])/(1 + Tanh[X]))^-k == -(JacobiP[2, 
        k, -k, Tanh[X]]/JacobiP[2, -k, k, Tanh[X]])}, {X, 0, 
   5}, {k, -Sqrt[16/3], Sqrt[16/3]}, MaxRecursion -> 2, 
  PlotPoints -> 100, PlotRange -> {{0, 5}, Full}, 
  FrameLabel -> Automatic, ContourStyle -> Blue, 
  PlotLegends -> Placed[{"-sign"}, {0.8, 0.12}], 
  Exclusions -> 
   Flatten[{k == 1, k == -1, JacobiP[2, -k, k, Tanh[X]] == 0}]]
g2 = ContourPlot[{((1 - Tanh[X])/(1 + Tanh[X]))^-k == 
    JacobiP[2, k, -k, Tanh[X]]/JacobiP[2, -k, k, Tanh[X]]}, {X, 0, 
   5}, {k, -Sqrt[16/3], Sqrt[16/3]}, MaxRecursion -> 2, 
  PlotPoints -> 100, PlotRange -> {{0, 5}, Full}, 
  FrameLabel -> Automatic, ContourStyle -> Red, 
  PlotLegends -> Placed[{"+sign"}, {0.8, 0.2}], 
  Exclusions -> 
   Flatten[{k == -2, k == 2, k == 0, 
     JacobiP[2, -k, k, Tanh[X]] == 0}]]
Show[g1, g2]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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