0
$\begingroup$

My problem is when I try to numerically solve an equation, and then substitute the solution in my function (i.e substituting y in the x's in my function), the plot appears to be discontinuous (it shouldn't) and I don't know what to do about it, I'm really new to the program.

My code is as follows:

y = NSolve[-a + t/(2 x) + 1/(8 Pi x^4) - 1/(8 Pi x^2) == 0, x];

f[x_] = 1/4 (x - 8 Pi/3 (a*x^3) + 3/x)

solution = Table[f[x] /. y, {a, {0.0013, 0.0033}}];

Plot[solution, {t, 0, 0.05}, PlotRange -> {0, 2}]

enter image description here

Both plots must be continuous and smooth, this is my main problem. Thank you for helping me.

$\endgroup$
4
  • $\begingroup$ Welcome to the Mathematica Stack Exchange. Could you please add a picture showing the discontinuous plot? And perhaps how you want it modified. At this point, it is not clear what you are asking. $\endgroup$
    – Syed
    Jun 19 at 13:15
  • 1
    $\begingroup$ Your functions have complex values. Plot shows the graph only when the imaginary part is zero. Try ReImPlot instead. $\endgroup$
    – Michael E2
    Jun 19 at 13:16
  • $\begingroup$ I uploaded a picture $\endgroup$ Jun 19 at 13:46
  • $\begingroup$ Thank you, Syed I appreciate your help $\endgroup$ Jun 19 at 13:58

1 Answer 1

0
$\begingroup$
y = NSolve[-a + t/(2 x) + 1/(8 Pi x^4) - 1/(8 Pi x^2) == 0, x, Reals];
f[x_] := 1/4 (x - 8 Pi/3 (a*x^3) + 3/x)
solution = Table[f[x] /. y, {a, {0.0013, 0.0033}}];
p1 = Plot[Evaluate@First@solution, {t, 0, 0.05}, PlotRange -> {0, 2}]
p2 = Plot[Evaluate@Last@solution, {t, 0, 0.05}, PlotRange -> {0, 2}]
GraphicsRow[{p1, p2}]

enter image description here

EDIT

Show[p1, p2]

enter image description here

$\endgroup$
1

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.