MathGroup Archive 2008

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

Search the Archive

Re: NDSolve and vector functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg87872] Re: [mg87843] NDSolve and vector functions
  • From: Carl Woll <carlw at wolfram.com>
  • Date: Sat, 19 Apr 2008 03:33:24 -0400 (EDT)
  • References: <200804181110.HAA18763@smc.vnet.net>

dh wrote:

>Hello all,
>
>does anybody know a way to compute a vector valued function using 
>
>NDSolve without explicitely specifying all vector components. Here is a 
>
>simple example: Although NDSolve[{p'[t]==p[t],p[0]=={1,0}},p,{t,0,1}] works,
>
>NDSolve[{p'[t]==p[t]+{1,1},p[0]=={1,0}},p,{t,0,1}]
>
>does not work because p[t] in "p[t]+{1,1}"  is treated as a scalar and 
>
>the expression is evaluated to {1+p[t],1+p[t]} what is clearly not 
>
>intended. Even in "IdentityMatrix[2].p[t]+{1,1}" 
>
>"IdentityMatrix[2].p[t]" is treated like a scalar and added to the 
>
>components of {1,1}.
>
>do I miss something???
>
>Daniel
>
>
>  
>
A workaround is to define a function that takes on the desired value 
when it's input is numeric. For example:

c[_?NumericQ] = {1,1}

NDSolve[{p'[t]==p[t]+c[t],p[0]=={1,0}},p,{t,0,1}]

Carl Woll
Wolfram Research



  • Prev by Date: Mathematica syntax
  • Next by Date: Re: Product command with matrices
  • Previous by thread: NDSolve and vector functions
  • Next by thread: Re: NDSolve and vector functions