NDSolve/InterpolatingFunction and vectors
- To: mathgroup at smc.vnet.net
- Subject: [mg53657] NDSolve/InterpolatingFunction and vectors
- From: D Herring <dherring at at.uiuc.dot.edu>
- Date: Fri, 21 Jan 2005 06:37:09 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Hi all,
For numerous reasons (such as dot products), I would like to use NDSolve
with vector-valued functions.
For example, the Sine and Cosine could be defined as
soln=NDSolve[{
xx'[t]\[Equal]{{0,1},{-1,0}}.xx[t],xx[0]\[Equal]{{0},{1}}
},xx,{t,0,10}]
Then I have the multi-valued function
f[t_]=(xx/.soln[[1]])[t]
such that f[Pi] is roughly {{0},{-1}} as expected.
The trouble comes when trying to extract scalar values from f[t].
f[3.14][[1,1]] ~= 0 but f[t][[1,1]] throws an error.
Likewise, Plot[f[t],{t,0,10}] pukes because f[t] doesn't return a
scalar when evaluated.
My current solution uses dot products to extract values.
{1,0}.f[t] doesn't error since it holds until f is evaluated.
Plot[{{1,0},{0,1}}.f[t],{t,0,10}] still bombs, but
Plot[{{1,0}.f[t],{0,1}.f[t]},{t,0,10}] works fine.
Can anyone suggest a better overall method for embedding dot products in
NDSolve? The system I have looks something like
{p'[t]=dp[p]+(p[t]-a[s[t]]).dads[s[t]], s'[t]=p'[t].dads[s[t]]/...)
where a[s] is given. t and s[t] are scalar; the other variables are of
dimension 4 (or more).
Thanks,
Daniel
- Follow-Ups:
- Re: NDSolve/InterpolatingFunction and vectors
- From: DrBob <drbob@bigfoot.com>
- Re: NDSolve/InterpolatingFunction and vectors