Re: NDSolve[]
- To: mathgroup at smc.vnet.net
- Subject: [mg123514] Re: NDSolve[]
- From: "Nasser M. Abbasi" <nma at 12000.org>
- Date: Sat, 10 Dec 2011 07:26:22 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <jbsq3f$3ul$1@smc.vnet.net>
- Reply-to: nma at 12000.org
> For the same equations, why does the first method as following give
> the error but the other one give the desired result?
>
> NDSolve[{Derivative[x[t], t] == -y[t] - x[t]^2,
> Derivative[y[t], t] == 2*x[t] - y[t], x[0] == y[0] == 1}, {x,
> y}, {t, 10}]
>
> NDSolve[{x'[t] == -y[t] - x[t]^2, y'[t] == 2*x[t] - y[t],
> x[0] == y[0] == 1}, {x, y}, {t, 10}]
>
Need to use Derivative[1][x][t] and not Derivative[x[t], t] :
--------------------------------------------
sol = First@
NDSolve[{Derivative[1][x][t] == -y[t] - x[t]^2,
Derivative[1][y][t] == 2*x[t] - y[t], x[0] == y[0] == 1}, {x,
y}, {t, 10}]
Plot[x[t] /. sol, {t, 0, 10}]
----------------------------------------------
---------------------------------------
sol = First@
NDSolve[{x'[t] == -y[t] - x[t]^2, y'[t] == 2*x[t] - y[t],
x[0] == y[0] == 1}, {x, y}, {t, 10}];
Plot[x[t] /. sol, {t, 0, 10}]
---------------------------------------------
--Nasser