Re: NDSolve[]
- To: mathgroup at smc.vnet.net
- Subject: [mg123535] Re: NDSolve[]
- From: DrMajorBob <btreat1 at austin.rr.com>
- Date: Sat, 10 Dec 2011 07:30:10 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <201112091058.FAA03928@smc.vnet.net>
- Reply-to: drmajorbob at yahoo.com
The first method has invalid syntax for Derivative. Here are three correct
solutions:
{x1, y1} = {x, y} /.
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}];
{x2, y2} = {x, y} /.
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}];
{x3, y3} = {x, y} /.
First@NDSolve[{D[x[t], t] == -y[t] - x[t]^2,
D[y[t], t] == 2*x[t] - y[t], x[0] == y[0] == 1}, {x, y}, {t,
10}];
Row@{Plot[{x1@t, y1@t}, {t, 0, 10}, ImageSize -> 250],
Plot[{x2@t, y2@t}, {t, 0, 10}, ImageSize -> 250],
Plot[{x3@t, y3@t}, {t, 0, 10}, ImageSize -> 250]}
Bobby
> Z
> Subject: NDSolve[]
> To: mathgroup at smc.vnet.net
>
> 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}]
>
--
DrMajorBob at yahoo.com
- References:
- [no subject]
- From: "Steven M. Christensen" <steve@smc.vnet.net>
- [no subject]