Troubleshooting NDSolve Errors: Non-Numerical Values in ODE Integration

In summary, you can specify initial conditions for your ODEs in Mathematica by using the InitialConditions option in the NDSolve function. You can also solve a system of ODEs with different numbers of equations and dependent variables, plot the solution, solve higher order ODEs, and incorporate parameters into your ODEs using the NDSolve and ParametricNDSolve functions.
  • #1
JohnSimpson
92
0
I'm having a problem with NDSolve. See attached picture. I have a package generating a set of ODE's, which I display, and then the next line is the NDSolve integration. I get an "Encountered non-numerical value for a derivative at t==0" error, and I can't spot the mistake. The one thing that looks suspicious to me is the terms in the Equations of Motion that look like "0.05.2". It looks like it should be "0.05*2", but I don't understand why it doesn't just evaluate it.

Best Wishes
-John
 

Attachments

  • Mathematica.jpg
    Mathematica.jpg
    44.7 KB · Views: 395
Physics news on Phys.org
  • #2
Please Ignore. I found my problem!
 

Related to Troubleshooting NDSolve Errors: Non-Numerical Values in ODE Integration

1. How do I specify initial conditions for my ODEs in Mathematica?

To specify initial conditions for your ODEs in Mathematica, you can use the InitialConditions option in the NDSolve function. For example, if your ODEs are y''[t] + y[t] == 0 and you want to specify that y[0] = 1 and y'[0] = 0, you can use the code NDSolve[{y''[t] + y[t] == 0, InitialConditions -> {y[0] == 1, y'[0] == 0}}, y[t], {t, 0, 10}].

2. Can I solve a system of ODEs with different numbers of equations and dependent variables in Mathematica?

Yes, you can solve a system of ODEs with different numbers of equations and dependent variables in Mathematica. You can do this by using the NDSolve function with a list of equations and initial conditions. For example, if your system of ODEs is y''[t] + y[t] == 0 and x''[t] + x[t] == 0 with initial conditions y[0] = 1, y'[0] = 0, x[0] = 2, and x'[0] = 0, you can use the code NDSolve[{{y''[t] + y[t] == 0, x''[t] + x[t] == 0}, {y[0] == 1, y'[0] == 0, x[0] == 2, x'[0] == 0}}, {y[t], x[t]}, {t, 0, 10}].

3. How can I plot the solution to my ODEs in Mathematica?

You can plot the solution to your ODEs in Mathematica by using the Plot function. For example, if you have solved the ODE y''[t] + y[t] == 0 and want to plot the solution from t = 0 to t = 10, you can use the code Plot[y[t] /. sol, {t, 0, 10}], where sol is the solution obtained from using the NDSolve function.

4. Can I use Mathematica to solve higher order ODEs?

Yes, you can use Mathematica to solve higher order ODEs. You can do this by rewriting the higher order ODE as a system of first order ODEs. For example, if you have a second order ODE y''[t] + y'[t] + y[t] == 0, you can rewrite it as {y'[t] == z[t], z'[t] == -y[t] - z[t]} and then use the NDSolve function to solve the system.

5. Is it possible to incorporate parameters into my ODEs in Mathematica?

Yes, it is possible to incorporate parameters into your ODEs in Mathematica. You can do this by using the ParametricNDSolve function. This allows you to specify values for the parameters and then vary them to see how the solution changes. For example, if your ODE is y''[t] + a y[t] == 0 and you want to vary the parameter a, you can use the code ParametricNDSolve[{y''[t] + a y[t] == 0, y[0] == 1, y'[0] == 0}, y, {t, 0, 10}, {a}]. You can then use the Manipulate function to vary the value of a and see how the solution changes.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
7K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
13
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • Programming and Computer Science
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
Back
Top