2
$\begingroup$

I have a function defined as:

$\rho_{m}\left(\epsilon,m\right)=\left[-2\epsilon r\pm\left(4\epsilon^{2}r^{2}+m\lambda r^{3}\right)^{\frac{1}{2}}\right]^{\frac{1}{2}}$

I want to plot it for some $m\in \mathbb{Z}$, so I wrote this code:

Clear[r,\[Lambda]];
\[Lambda]=685*10^-9;
r=25*10^-3;
\[Rho]1[\[Epsilon]_,m_]=(-2*\[Epsilon]*r+(4*\[Epsilon]^2*r^2+m*\[Lambda]*r^3)^(1/2))^(1/2);
\[Rho]2[\[Epsilon]_,m_]=(-2*\[Epsilon]*r-(4*\[Epsilon]^2*r^2+m*\[Lambda]*r^3)^(1/2))^(1/2);
M=Range[-5,5,1];
p1=Show[Plot[\[Rho]1[\[Epsilon]*10^-3,#]*10^3, {\[Epsilon],-0.5,0.5}, PlotRange -> {{-0.5,0.5},{0, 5}},AxesOrigin->{-0.5,0},PlotTheme->"Monochrome"] & /@ M];
p2=Show[Plot[\[Rho]2[\[Epsilon]*10^-3,#]*10^3, {\[Epsilon],-0.5,0.5}, PlotRange -> {{-0.5,0.5},{0, 5}},AxesOrigin->{-0.5,0},PlotTheme->"Monochrome"] & /@ M];
Show[{p1,p2}]

Which outputs:

enter image description here

However, there are some tiny gaps where the two functiosn meet, but I was expecting them to be continuous. How can I fix that?

$\endgroup$
  • $\begingroup$ Adding the option PlotPoints->1000 to both your Plots will make those gaps much less visible. $\endgroup$ – Bill Apr 26 at 19:19
  • $\begingroup$ I think that the problem may be that the functions become imaginary at $\epsilon = 0$. Plot doesn't plot anything at all when the value is imaginary. When it happens precisely at the point where they're supposed to meet I guess it becomes a numerical issue, hence why PlotPoints may help. $\endgroup$ – C. E. Apr 26 at 19:38
5
$\begingroup$

If you turn the equation around and plot $\epsilon$ as a function of $\rho$, then there are no gaps and no branches:

λ = 685*10^-9;
r = 25*10^-3;
ParametricPlot[Table[10^3 {(m r^3 λ - ρ^4)/(4 r ρ^2), ρ}, {m, -5, 5}],
  {ρ, 0, 5*10^-3}, AspectRatio -> 1/GoldenRatio]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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