Using Mathematica to solve an ODE

In summary, to use Mathematica to solve an ODE, you will need to define the differential equation using the syntax <code>eqn = y''[x] == f[x]</code>, and then use the <code>DSolve</code> command to obtain the general or particular solution. If you have initial conditions, you can include them in the <code>DSolve</code> command. Mathematica can solve ODEs of any order, and you can plot the solution using the <code>Plot</code> command. It is also possible to solve systems of ODEs in Mathematica by defining the equations and using the <code>DSolve</code> command with a list of the equations.
  • #1
Ashley1nOnly
132
3

Homework Statement


upload_2018-9-4_13-2-12.png


Homework Equations


upload_2018-9-4_13-1-2.png

upload_2018-9-4_13-1-36.png


The Attempt at a Solution



I used the NDSolve function from mathematic but its giving me problems. What is the correct way to enter the equation?[/B]
soln = NDSolve[{y''[t] = (-9.8/5)*sin (t), y[0] = 20, y, {x, 0, 12}}]
 

Attachments

  • upload_2018-9-4_13-1-2.png
    upload_2018-9-4_13-1-2.png
    1 KB · Views: 590
  • upload_2018-9-4_13-1-36.png
    upload_2018-9-4_13-1-36.png
    1.1 KB · Views: 565
  • upload_2018-9-4_13-2-12.png
    upload_2018-9-4_13-2-12.png
    28.2 KB · Views: 554
Physics news on Phys.org
  • #2
(1) The right hand side is not sin(t), it is sin(y[t]).

(2) Look more carefully at the syntax of the Mathematica NDSolve example below. Is your input in this form?

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

1. How do I use Mathematica to solve an ODE?

To use Mathematica to solve an ODE, you will need to define the differential equation using the syntax eqn = y''[x] == f[x], where y[x] is the dependent variable and f[x] is the right-hand side of the equation. Then, use the command DSolve[eqn, y[x], x] to solve the ODE and obtain the general solution.

2. What if I have initial conditions for my ODE?

If you have initial conditions for your ODE, you can include them in the DSolve command by adding the syntax y[x0] == y0, y'[x0] == y0', where x0 is the initial value of the independent variable and y0 is the initial value of the dependent variable. This will give you the particular solution that satisfies the given initial conditions.

3. Can Mathematica solve higher-order ODEs?

Yes, Mathematica can solve ODEs of any order. You will need to define the equation using the appropriate syntax, such as y'''[x] == g[x] for a third-order ODE. Then, use the DSolve command as usual to obtain the general or particular solution.

4. How can I plot the solution to my ODE in Mathematica?

To plot the solution to your ODE, you can use the Plot command. For example, if you have the solution y[x] = x^2 + 2x + 1, you can plot it by entering Plot[x^2 + 2x + 1, {x, 0, 10}]. This will give you a plot of y[x] from x = 0 to x = 10.

5. Can I solve a system of ODEs in Mathematica?

Yes, Mathematica can solve systems of ODEs. You will need to define the equations using the appropriate syntax, such as eqn1 = y1''[x] == f1[x] and eqn2 = y2''[x] == f2[x]. Then, use the DSolve command with a list of the equations, such as DSolve[{eqn1, eqn2}, {y1[x], y2[x]}, x], to obtain the solutions for both dependent variables.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
134
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • Programming and Computer Science
Replies
1
Views
1K
  • Introductory Physics Homework Help
Replies
21
Views
841
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • Introductory Physics Homework Help
Replies
2
Views
2K
  • Introductory Physics Homework Help
Replies
1
Views
932
Replies
24
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
261
  • Introductory Physics Homework Help
Replies
7
Views
1K
Back
Top