How to plot the result of NDSolve?

  • Thread starter Thread starter panzer7910
  • Start date Start date
  • Tags Tags
    Plot
Click For Summary
SUMMARY

This discussion focuses on plotting results from the NDSolve function in Mathematica, specifically for nine coupled nonlinear differential equations. Users are guided on how to extract and plot individual functions using the InterpolatingFunction generated by NDSolve. The necessity of using the Evaluate command in conjunction with the substitution operator (/. s) is emphasized for proper function evaluation. Key references to Mathematica documentation are provided for further clarification on expression handling.

PREREQUISITES
  • Familiarity with Mathematica 12.0 and its NDSolve function.
  • Understanding of InterpolatingFunction in Mathematica.
  • Knowledge of plotting functions using the Plot command in Mathematica.
  • Basic concepts of differential equations and their numerical solutions.
NEXT STEPS
  • Learn how to use Mathematica's InterpolatingFunction for plotting multiple functions.
  • Explore the Evaluate command in Mathematica to understand its role in expression evaluation.
  • Study the documentation on ReplaceAll (/. operator) for effective substitutions in Mathematica.
  • Investigate advanced techniques for solving and visualizing coupled differential equations in Mathematica.
USEFUL FOR

Mathematica users, mathematicians, and engineers working with differential equations and seeking to visualize complex solutions effectively.

panzer7910
Messages
2
Reaction score
0
1) I solved 9 coupled non linear differential equation and Mathematica give me the result like this.

{{y1[t]->InterpolatingFunction[{{0.001,0.01}},<>][t],
y2[t]->InterpolatingFunction[{{0.001,0.01}},<>][t],
y3[t]->InterpolatingFunction[{{0.001,0.01}},<>][t],
y4[t]->InterpolatingFunction[{{0.001,0.01}},<>][t],
y5[t]->InterpolatingFunction[{{0.001,0.01}},<>][t],
y6[t]->InterpolatingFunction[{{0.001,0.01}},<>][t],
y7[t]->InterpolatingFunction[{{0.001,0.01}},<>][t],
y8[t]->InterpolatingFunction[{{0.001,0.01}},<>][t],
y9[t]->InterpolatingFunction[{{0.001,0.01}},<>][t]}}

How can I plot each of the function (y1 to y9) separately?

2) To solve a single differential equation (refer to the Mathematica NDSolve Help) and plot it, why we must divide by the answer itself? I mean, in this case, why should I divide by " .s " ?

s = NDSolve[{y'[x] == y[x] Cos[x + y[x]], y[0] == 1}, y, {x, 0, 30}]

Plot[Evaluate[y[x] /. s], {x, 0, 30}, PlotRange -> All]
 
Physics news on Phys.org
Hey panzer7910 and welcome to the forums.

Upon looking into the documentation, the expression with the s has to do with expression simplification. Remember that you have an Evaluate command nested within, and this will evaluate an expression with your ./ s parameter.

What looks to be happening is that it is making a substitution so that the function actually gets evaluated instead of having a purely symbolic representation, but I would double check.

http://reference.wolfram.com/mathematica/guide/Expressions.html

http://reference.wolfram.com/mathematica/ref/ReplaceAll.html

http://reference.wolfram.com/mathematica/guide/Rules.html

http://reference.wolfram.com/mathematica/ref/ReplaceAll.html
 

Similar threads

  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 6 ·
Replies
6
Views
9K
Replies
4
Views
3K
  • · Replies 10 ·
Replies
10
Views
6K