I am trying to plot a derivative versus the variable using ParametricPlot. Whenever I evaluate the two functions manually, I can manually find values for certain x, leading me to think that it should be able to plot something. Other related questions here only solve specific problems with the functions so I have not been able to improve my code with the answers I found.
The following is a minimum working example (sorry for the many definitions):
Some definitions:
Zc = (11 + 5*Sqrt[5])/(2)
Q[x_, n_] := Product[1 - x^i, {i, n}]
P[x_, n_] := Product[1 - x^(2 i - 1), {i, n}]
H[x_, n_] := Product[1/((1 - x^(5 i - 3))*(1 - x^(5 i - 2))), {i, n}]
G[x_, n_] :=
Product[(1/((1 - x^(5 i - 4))*(1 - x^(5 i - 1)))), {i, n}]
z[x_, n_] := (-x*(H[x, n]^5))/(G[x, n]^5)
ρ[x_, n_] := (-x*G[x, n]*H[x^6, n]*P[x^3, n])/(P[x, n])
dρdx[a_, n_] := D[ρ[x, n], x] /. x -> a
dzdx[a_, n_] := D[z[x, n], x] /. x -> a
dρdz[x_, n_] := dρdx[x, n]/dzdx[x, n]
Some styling:
lineStyle = {Red, Dashed};
lineZc = Line[{{Zc, 0}, {Zc, 10}}];
The ParametricPlot call:
Quiet[
ParametricPlot[
{z[x, 10], dρdz[x, 10]}, {x, -1, 1},
ImageSize -> Large,
AspectRatio -> 1/2,
PlotLabel ->
"Rate of change of density vs. fugacity around \!\(\*SubscriptBox[\
\(z\), \(c\)]\) for n=100",
Prolog -> {Directive[lineStyle], lineZc},
PlotLegends -> {"z<\!\(\*SubscriptBox[\(z\), \(c\)]\)",
"z>\!\(\*SubscriptBox[\(z\), \(c\)]\)"},
PlotPoints -> 1000,
AxesLabel -> {"z", "\!\(\*FractionBox[\(dρ\), \(dz\)]\)"},
PlotRange -> Automatic
]
]
I am a new user so sorry if not all the formatting is up to par, let me know if I have to change anything.
Currently, my only guess is that is has to do something with the ReplaceAll
command I am using for the derivatives, but I do not know how to dodge this way.
PadeApproximant
or useSeries
to get suitable approximations for selected domains; these are often quite useful in numericizing analytic functions... When you have found suitable rational expression, you can applyCompile
to them for getting performance. $\endgroup$