Solve ODEs w/ Mathematica & Compute Derivative of Niles

  • Mathematica
  • Thread starter Niles
  • Start date
  • Tags
    Mathematica
In summary, the conversation discusses a system of ODEs and finding a way to use the derivative of the solution in a given expression. The solution can be found using NDSolve, and the derivative can be obtained by inverting the solution using FindRoot.
  • #1
Niles
1,866
0
Hi

I have a system of ODEs of the form

dx/dt = v
dv/dt = a = C*f(x),

where C denotes a constant and f(x) is some function of x. This system is easy to solve using (e.g.)
Code:
NDSolve[x''[t] == C*f(x), x[0] == 0, x'[0] == 0}, x, {t, 0, tMax}];
I need to use the derivative of the solution x[t], x'[t], in the following expression: B(x) = A + v(x), where A denotes a constant. But please note that the derivative is needed as a function of x, not t. I've been trying to figure out a smart way to do this, but I can't wrap my head around this. What should I do to achieve this?Niles.
 
Last edited:
Physics news on Phys.org
  • #2
Since you have x[t], you need to invert this to find t[x], then, since you know v[t], your v[x] is given by v[t[x]]. If you have an analytic solution, you can do this analytically, but if you have a numerical solution, the easiest way to invert it is probably with FindRoot. See the attached notebook.
 

Attachments

  • NDSolve.nb
    24 KB · Views: 392
  • #3
Thanks, that is very kind of you.Niles.
 

1. How can I solve ordinary differential equations (ODEs) using Mathematica?

To solve ODEs using Mathematica, you can use the built-in function "DSolve" which takes in the ODE and initial conditions as input. For example, if you have the ODE y''(x) + y'(x) + y(x) = 0 with initial conditions y(0) = 1 and y'(0) = 0, you can use the code "DSolve[{y''[x] + y'[x] + y[x] == 0, y[0] == 1, y'[0] == 0}, y[x], x]" to find the solution.

2. Can Mathematica compute derivatives of functions?

Yes, Mathematica has a built-in function called "D" which can be used to compute derivatives of functions. For example, if you have the function f(x) = x^2, you can use the code "D[x^2, x]" to compute the derivative which will give you 2x.

3. What is the significance of using Niles in solving ODEs?

Niles is a powerful numerical solver for ODEs that is built into Mathematica. It uses high-precision algorithms to provide accurate and efficient solutions to ODEs. It is especially useful for solving stiff ODEs that can be challenging for other methods.

4. Can I plot the solutions to ODEs using Mathematica?

Yes, you can use the built-in function "Plot" to plot the solutions to ODEs. For example, if you have the ODE y''(x) + y'(x) + y(x) = 0 with initial conditions y(0) = 1 and y'(0) = 0, you can use the code "Plot[Evaluate[y[x] /. sol], {x, 0, 10}]" to plot the solution over the range of x from 0 to 10.

5. Is there a limit to the complexity of ODEs that Mathematica can solve?

Yes, there may be some ODEs that are too complex for Mathematica to solve. However, Mathematica is constantly updating and improving its algorithms, so it is able to solve a wide range of ODEs. If you encounter an ODE that Mathematica cannot solve, there are also other numerical solvers and techniques that can be used to find a solution.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
217
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
257
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • Programming and Computer Science
Replies
1
Views
1K
  • Calculus and Beyond Homework Help
Replies
4
Views
493
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
932
Replies
3
Views
788
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
7K
Back
Top