Register to reply

Mathematica differential equation

by P-Jay1
Tags: differential, equation, mathematica
Share this thread:
Nov25-11, 05:13 AM
P: 35
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].

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?
Phys.Org News Partner Science news on
'Office life' of bacteria may be their weak spot
Lunar explorers will walk at higher speeds than thought
Philips introduces BlueTouch, PulseRelief control for pain relief
Nov25-11, 05:55 AM
P: 313
You have x3'[0] instead of x'[0].
That's the only problem....
Nov25-11, 06:53 AM
P: 35
Quote Quote by Simon_Tyler View Post
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?

Bill Simpson
Nov25-11, 09:38 AM
P: 1,043
Mathematica differential equation

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.
Attached Files
File Type: nb nd.nb (3.7 KB, 0 views)
Nov25-11, 07:50 PM
P: 313
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...

Register to reply

Related Discussions
Simple Differential Equation (Ordinary Differential Equation) Differential Equations 7
Mathematica Differential Equation, help me see whats wrong Advanced Physics Homework 1
Graphing a differential equation in mathematica? Advanced Physics Homework 0
Differential Equation and Mathematica Math & Science Software 4
Mathematica Help with nonlinear differential? Math & Science Software 2