This question already has an answer here:

I would like to get this graphic:

enter image description here

from this article. Here $\kappa$ and $\varepsilon_{dd}$ are related by:

ekappa[k_, edd_, l_] := 
 3*k*edd ((l^2/2 + 1) fs[k]/(1 - k^2) - 1) + (edd - 1) (k^2 - l^2)

where $f_s(\kappa)$ is given by:

fs[k_] := (1 + 2 k^2)/(1 - k^2) - 
  3 k^2*ArcTanh[Sqrt[1 - k^2]]/(1 - k^2)^(3/2)

Here is my attempt:

g[edd_?NumericQ] := FindRoot[ekappa[k, edd, 0.5], {k, 0}]
Plot[g[edd], {edd, 0, 1.6}]

but I do not get the graphic. Could you help me?


marked as duplicate by march, m_goldberg plotting May 13 at 3:51

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


It looks like k=1 will give you a problem, as well as any k>1. Therefore I would change the starting value and search region for k in FindRoot.

g[edd_?NumericQ] := FindRoot[ekappa[k, edd, 0.5], {k, 0.5, 0.01, 0.99}]

Notice that this returns a rule, rather than a value:


{k -> 0.174197}

One way to get around this is to plot k/.g[edd]

Plot[k /. g[edd], {edd, 0, 1.6}]

enter image description here

An alternative is to redefine g to return a value

g2[edd_?NumericQ] := FindRoot[ekappa[k, edd, 0.5], {k, 0.5, 0.01, 0.99}][[1, 2]]


Plot[g2[edd], {edd, 0, 1.6}]

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