Mathematica differential equation

In summary, the conversation discusses solving a differential equation numerically on Mathematica, with the goal of plotting the solution for a given domain. The correct code for solving the equation is provided and explained, with an emphasis on using the correct notation for variables. The benefits of solving for a pure interpolated function are also mentioned.
  • #1
32
0
On mathematica:
Solve the differential equation

d^2 x(t)/dt^2 + x(t)(x^2(t) − 1) + t = 0

numerically, subject to the initial conditions that x(0) = 1 and dx(0)/dt = 0. Use
Plot to plot the solution for the domain t 2 [0, 10].
2.

Above is what I'm trying to do. Below is what I've typed in on mathematica:

s = NDSolve[{x''[t] + (x[t]) (x[t]^2 - 1) + t == 0, x[0] == 1,
x3'[0] == 0}, x, {t, 0, 10}]

This is wrong, it says it's not a diff. equation. Where am i going wrong?
 
Physics news on Phys.org
  • #2
You have x3'[0] instead of x'[0].
That's the only problem...
 
  • #3
Simon_Tyler said:
You have x3'[0] instead of x'[0].
That's the only problem...

Sorry that was mistake, but it's still wrong, I've tryed everything i can think of.

n = NDSolve[{x''[t] + x[t] (x^2[t] - 1) + t == 0, x[0] == 1,
x'[0] == 0}, x[t], t, {t, 0, 10}]

above is what i got. Says duplicate variable t found, so it's still wrong. I'm not sure what to do, any ideas?
 
  • #4
I have fought with the obsession of both Mathematica and the forum software to translate characters into what they think are best for your, despite that breaking this going in both directions.

Attached is a tiny working notebook. Do a binary byte-by-byte comparison with what you have in your notebook and see what is different.
 

Attachments

  • nd.nb
    3.7 KB · Views: 430
  • #5
P-Jay: No, making the correction I suggested in your original code worked.
You've changed your code in your second post. It can be corrected by changing
x^2[t] -> x[t]^2
and by removing the extra t argument you had.

n2 = NDSolve[{x''[t] + x[t] (x[t]^2 - 1) + t == 0, x[0] == 1, x'[0] == 0}, x[t], {t, 0, 10}]

Finally, your first version was better, since you solved for x instead of x[t].
The former returns a pure interpolated function, while the latter returns the function evaluated at t, which is not as flexible.

For example, using the former version

n1 = NDSolve[{x''[t] + x[t] (x[t]^2 - 1) + t == 0, x[0] == 1, x'[0] == 0}, x, {t, 0, 10}]

you can plot the function and its derivative easily

Plot[Evaluate[{x[t], x'[t]} /. n1], {t, 0, 10}]

Doing the same with n2 is not as straight forward...
 

1. What is Mathematica differential equation?

Mathematica is a powerful software program used for mathematical and scientific calculations, including solving differential equations. It offers a wide range of methods for solving differential equations, including both numerical and symbolic methods.

2. How do I input a differential equation into Mathematica?

To input a differential equation into Mathematica, you can use the function DSolve or NDSolve depending on whether you want a symbolic or numerical solution. The syntax for these functions varies depending on the type of differential equation and any additional conditions or parameters.

3. Can Mathematica solve any type of differential equation?

Mathematica has the ability to solve many different types of differential equations, including ordinary differential equations, partial differential equations, and systems of differential equations. However, there may be some types of equations that it cannot solve or may require additional input or assumptions.

4. How accurate are the solutions provided by Mathematica for differential equations?

The accuracy of the solutions provided by Mathematica depends on the accuracy of the input and the method used to solve the differential equation. Symbolic solutions are generally more accurate than numerical solutions, but may not always be possible. It is important to check the accuracy of the solution and adjust the parameters or methods if needed.

5. Can I plot the solutions to a differential equation using Mathematica?

Yes, Mathematica has built-in functions for plotting the solutions to differential equations. You can use Plot or ParametricPlot for one-dimensional solutions, or Plot3D or ParametricPlot3D for two-dimensional solutions. You can also use VectorPlot to visualize vector fields associated with a system of differential equations.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
129
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
89
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
822
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
1K
Back
Top