I'm an absolute beginner using Mathematica just to solve a pair of non-linear ODEs and I'm struggling a bit with the lingo. The solutions come out as x -> InterpolatingFunction[-]
, y -> InterpolatingFunction[-]
. Both are functions purely of time.
All I want to do now is to extract a few values from these (or the corresponding plots if easier), namely gradients at certain points, and points with certain gradients. Things like Grad
and FindMaximum
don't seem to work.
Can anyone help? Even if its just a bit of code I can copy to get them?
Here is what I have so far:
s = NDSolve[{x'[t] == -(y[t]^-1) x[t]^(7/2) (0.99*10^-9) - y[t] x[t]^(-1/2) (0.24*10^-3),
y'[t] == x[t]^(5/2) (0.99*10^-9) - (y[t]^2) (x[t]^(-3/2)) (1.21*10^-3),
x[0] == 1.5*10^7, y[0] == 10^10},
{x, y}, {t, 0, 4000}]
Two ODEs with initial conditions and time boundaries.
And I plot it
TP = Plot[x[t] /. s, {t, 0, 400}]
NP = Plot[y[t] /. s, {t, 0, 400}]
NDSolve[]
returns a function you can differentiate. For instance:yf = y /. First[NDSolve[{y'[x] == -y[x], y[0] == 1}, y, {x, 0, 1}]]; Table[yf'[x], {x, 0, 1, 1/10}]
$\endgroup$