0
$\begingroup$

I Have numerically solved these two coupled equations, but I need to know how to scale the x-axis in the plot by a factor of (1/20)

pde1 = -y1''[x] - (2*y1'[x])/x + ((y1[x])^3 + y2[x])y1[x] == 0;
 pde2 = y2''[x] + (2y2'[x])/x - (y1[x])^3 == 0;
  sol = NDSolve[ {pde1, pde2, y1[20] == 0.001, y2[20] == -0.001,
  y1'[0.001] == 0.001, y2'[0.001] == 0.001}, {y1, y2}, {x,0.001, 20}]

I have $x=(1/20)\tilde{x}$ I need to plot $y1(\tilde{x})$

$\endgroup$
2
  • $\begingroup$ Do you mean something like this? p1 = Plot[Evaluate[y1[x] /. sol], {x, 0.001, 20}, PlotRange -> All]; p2 = Plot[Evaluate[y1[x] /. sol], {x, 0.001, 20}, PlotRange -> All, AspectRatio -> 20]; Grid[{{p1, p2}}] screen shot !Mathematica graphics or do you mean something else? $\endgroup$
    – Nasser
    May 14, 2023 at 7:43
  • $\begingroup$ I mean in my equations I have $x=(1/20)\tilde{x}$ I need to plot $y1(\tilde{x})$ $\endgroup$ May 14, 2023 at 19:18

1 Answer 1

1
$\begingroup$

have x=(1/20)x~ I need to plot y1(x~)

Ok, so $\hat{x} = 20 x$, right? So why not plot $y_1(20 x)$? Like this (You need to also scale the range at same time)

pde1 = -y1''[x] - (2*y1'[x])/x + ((y1[x])^3 + y2[x]) y1[x] == 0;
pde2 = y2''[x] + (2 y2'[x])/x - (y1[x])^3 == 0;
sol = NDSolve[{pde1, pde2, y1[20] == 0.001, y2[20] == -0.001, 
   y1'[0.001] == 0.001, y2'[0.001] == 0.001}, {y1, y2}, {x, 0.001, 20}]

Now instead of

p1 = Plot[Evaluate[y1[x] /. sol], {x, 0.001, 20}, PlotRange -> All]

Mathematica graphics

Do

scale = 1/20;
p1 = Plot[Evaluate[y1[1/scale*x] /. sol], {x, scale*0.001, scale*20}, PlotRange -> All]

Mathematica graphics

If this is still not what you want, will delete this.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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