Plotting y''[x] vs. y[x] in Mathematica with NDSolve

  • Context: Mathematica 
  • Thread starter Thread starter Niles
  • Start date Start date
  • Tags Tags
    Mathematica
Click For Summary

Discussion Overview

The discussion revolves around plotting the second derivative of a function against the function itself using Mathematica, specifically in the context of solving a differential equation with NDSolve. Participants explore methods for visualizing the relationship between y''[x] and y[x] while addressing issues related to plot ranges.

Discussion Character

  • Technical explanation
  • Mathematical reasoning

Main Points Raised

  • One participant describes a method to plot y''[x] against y[x] using ParametricPlot after solving a differential equation with NDSolve.
  • Another participant expresses a concern about the inability to set independent ranges for the x and y axes in the parametric plot.
  • A later reply suggests that using PlotRange -> {{0, 10}, {0, 5}} successfully allows for independent control of the ranges.

Areas of Agreement / Disagreement

Participants appear to agree on the method for plotting y''[x] against y[x], but there is a brief discussion regarding the control of plot ranges, which is resolved with a suggested solution.

Contextual Notes

The discussion does not delve into the assumptions or limitations of the differential equation being solved or the specific behavior of the solutions over the defined range.

Who May Find This Useful

Users of Mathematica interested in plotting solutions to differential equations and those looking for techniques to manipulate plot ranges in parametric plots may find this discussion beneficial.

Niles
Messages
1,834
Reaction score
0
Hi

Say I solve the following differential equation in Mathematica:
Code:
s = NDSolve[{y''[x] + Sin[y[x]] y[x] == 0, y[0] == 1, y'[0] == 0}, y, {x, 0, 30}]
Plot[Evaluate[{y[x], y'[x], y''[x]} /. s], {x, 0, 30}, PlotStyle -> Automatic]
The last line plots the solutions vs. x, but how can I plot e.g. y''[x] vs. y[x]?


Niles.
 
Physics news on Phys.org
ParametricPlot[Evaluate[{y[x], y''[x]} /. s], {x, 0, 30}]
 
Hi

Thanks for that. Whenever I try and alter the PlotRange, it changes both x and y. I guess that is reasonable, since it is a parametric plot. But is there any way for me to determine the range of x and y independently?Niles.
 
PlotRange -> {{0, 10}, {0, 5}} works. Thanks!
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K