Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #3969 > unrolled thread
| Started by | Gabriel Landi <gtlandi@gmail.com> |
|---|---|
| First post | 2011-07-25 11:36 +0000 |
| Last post | 2011-07-25 11:36 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: NDSolve in matrix form Gabriel Landi <gtlandi@gmail.com> - 2011-07-25 11:36 +0000
| From | Gabriel Landi <gtlandi@gmail.com> |
|---|---|
| Date | 2011-07-25 11:36 +0000 |
| Subject | Re: NDSolve in matrix form |
| Message-ID | <j0jkff$p2c$1@smc.vnet.net> |
Hi Glenn.
I solve a similar system in the following way:
Say it is defined as
X'(t) = a X(t) + b
Then once i know a,b and my initial conditions ic, i do:
vars = Table[f[i][t],{i,n}];
varsD = D[#,t ] &/@vars;
eqns = Flatten@{Thread[varsD == a.vars + b],
Thread[(vars /. t -> 0) == ic]};
sol = NDSolve[eqns,vars,{t,0,tf}]
Good luck,
Gabriel
On Jul 24, 2011, at 4:19 AM, Glenn Carlson wrote:
> I am trying to numerically solve systems of ODEs using Mathematica 7.
>
> The desired accuracy that I am striving for depends on the number of
solution functions so I want to structure my solution algorithm to allow
different numbers of solution functions. Solving the problem as a system
of ODEs in matrix form seems the logical choice:
>
> dX/dt = f[X[t]],
>
> where f[X[t]] is a specified function, and X[t] is a vector of
solution functions {x1[t],x2[t],...}. The initial conditions are
specified by a vector X[0] = {x1[0],x2[0],...}.
>
> In my problem, the number of solution functions will usually vary from
3 to 7, but could be any number.
>
> One approach that doesn't work is:
>
> f := {f[[1]][t], f[[2]][t], f[[3]][t]}
> fInit := {0, 0, 2}
> mat := {(-3*f[[1]][t] - f[[2]][t]), 26.5*f[[1]][t] - f[[2]][t] -
f[[1]][t]*f[[3]][t], f[[1]][t]*f[[2]][t] - f[[3]][t]}
> solution = NDSolve[{Derivative[1][f][t] == mat, f[0] ==
fInit}, f, {t, 0, 17}]
>
> I don't know if the problem is in the way f is specified or in my
expression for NDSolve.
>
> I'd appreciate any assistance.
>
> Thanks and regards,
>
> Glenn
>
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web