Re: NDSolve/InterpolatingFunction and vectors
- To: mathgroup at smc.vnet.net
- Subject: [mg53722] Re: NDSolve/InterpolatingFunction and vectors
- From: "Jens-Peer Kuska" <kuska at informatik.uni-leipzig.de>
- Date: Tue, 25 Jan 2005 05:03:19 -0500 (EST)
- Organization: Uni Leipzig
- References: <csqrsc$1sl$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi, soln = NDSolve[{ xx'[t] == {{0, 1}, {-1, 0}}.xx[t], xx[0] == {{0}, {1}} }, xx, {t, 0, 10}] Needs["DifferentialEquations`NDSolveUtilities`"] and time = DifferentialEquations`NDSolveUtilities`Private`GetTimeData[soln]; grid = First[ DifferentialEquations`NDSolveUtilities`Private`GetGridData[soln]]; ip1 = Interpolation[Transpose[{time, #[[1, 1, 1]] & /@ Transpose[grid]}]]; ip2 = Interpolation[Transpose[{time, #[[1, 2, 1]] & /@ Transpose[grid]}]] helps not ? at least Plot[{ip1[t], ip2[t]}, {t, 0, 10}] work fine. Regards Jens "D Herring" <dherring at at.uiuc.dot.edu> schrieb im Newsbeitrag news:csqrsc$1sl$1 at smc.vnet.net... > 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 >