Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #7091

Re: NDSolve[]

From DrMajorBob <btreat1@austin.rr.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: NDSolve[]
Date 2011-12-10 12:38 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jbvjsv$j3e$1@smc.vnet.net> (permalink)
References <201112091058.FAA03928@smc.vnet.net>

Show all headers | View raw


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@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@yahoo.com

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: NDSolve[] DrMajorBob <btreat1@austin.rr.com> - 2011-12-10 12:38 +0000

csiph-web