MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Q: NDSolve


Christoph Handel wrote:

>  is there a nice way to solve an equation like this:
>
> x'[t] == aMatrix[t] . x[t]
>
> where x ist a Vector.
>
> I tried something like this:
>
> NDSolve[{x'[t]== aMatrix[t] . x[t], x[0]=={1,2,3...}},x,{t,0,42}]

Here is a "reasonably" nice way which makes use of Through and Thread:

For the vector

  x = {a, b, c};

and the matrix

  A[t_] = {{1, 2 t, 7}, {4, 3, 9 - t^2}, {0, 0, 1}};

the set of differential equations can be written as

  eqn = Thread[D[Through[x[t]], t] == A[t] . Through[x[t]]]

Specifying the initial conditions,

  ics = Thread[Through[x[0]] == {1, 0, 2}]

we can now use NDSolve directly:

  NDSolve[Join[eqn, ics], x, {t, 0, 1}]

Cheers,
    Paul



  • Prev by Date: Re: Bessel J0 zeros
  • Next by Date: Fantastic Mathematica Book goes out of print
  • Previous by thread: Re: Q: NDSolve
  • Next by thread: Q: Preventing Subscripts from being interpreted as expressions?