I have a function SA[zs,zh]
where I want to do a ParametricPlot
of a Piecewise
function with the x-axis being tzs[zs,zh]
. I have tried using ConditionalExpression
, it produces the plot but there is a "gap" between the two piecewise components. I also tried to use Piecewise
directly but it won't plot the second component (a constant) of the piecewise.
I want to know,
- Why there is a "gap" between the two piecewise components when using
ConditionalExpression
and how to resolve it? - Why the second component of the piecewise function won't plot when using
Piecewise
?
I have checked my code and there seem to be no problem at all.
d = 3;
ag = 10;
pg = 10;
wp = 20;
f[z_, zh_] := 1 - (z/zh)^(d + 1);
tzsint[z_?NumericQ, zs_?NumericQ, zh_?NumericQ] := z^d/Sqrt[f[z, zh] (zs^(2 d) - z^(2 d))]
tzs[zs_?NumericQ, zh_?NumericQ] := Module[{zsr, zhr}, {zsr, zhr} = Rationalize[{zs, zh}, 0]; NIntegrate[tzsint[z, zsr, zhr], {z, 0, zsr}, AccuracyGoal -> ag, PrecisionGoal -> pg, WorkingPrecision -> wp, MaxRecursion -> 100]]
SAint[z_?NumericQ, zs_?NumericQ, zh_?NumericQ] := (zs^d/(z^d Sqrt[f[z, zh] (zs^(2 d) - z^(2 d))]))
SAintreg[z_?NumericQ, zs_?NumericQ] := (zs^d/(z^d Sqrt[(zs^(2 d) - z^(2 d))]))
SA[zs_?NumericQ, zh_?NumericQ] := Module[{zsr, zhr}, {zsr, zhr} = Rationalize[{zs, zh}, 0]; NIntegrate[SAint[z, zsr, zhr] - SAintreg[z, zsr], {z, 0, zsr}, AccuracyGoal -> ag, PrecisionGoal -> pg, WorkingPrecision -> wp, MaxRecursion -> 100]]
ParametricPlot[{ConditionalExpression[{tzs[zs, 0.1355], SA[zs, 0.1355]}, zs <= 0.1354688], ConditionalExpression[{tzs[zs, 0.1355], SA[0.1354688, 0.1355]}, zs >= 0.1354688]}, {zs, 0, 0.9999943 0.1355}, Frame -> True, FrameStyle -> Directive[Black, 20], PlotStyle -> {{Blue, Thick}, {Blue, Thick}}, PlotRange -> Full, AspectRatio -> 3/4, ImageSize -> Large]
ParametricPlot[{tzs[zs, 0.1355], Piecewise[{{SA[zs, 0.1355], zs < 0.1354688}, {SA[0.1354688, 0.1355], 0.1354688 < zs}}]}, {zs, 0, 0.9999943 0.1355}, Frame -> True, FrameStyle -> Directive[Black, 20], PlotStyle -> {{Blue, Thick}, {Blue, Thick}}, PlotRange -> Full, AspectRatio -> 3/4, ImageSize -> Large]
Using ConditionalExpression
,
Using Piecewise
,