MathGroup Archive 2011

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

Search the Archive

Re: Incredible slow Plot

  • To: mathgroup at smc.vnet.net
  • Subject: [mg120184] Re: Incredible slow Plot
  • From: Iván Lazaro <gaminster at gmail.com>
  • Date: Tue, 12 Jul 2011 06:58:18 -0400 (EDT)
  • References: <iv9etb$dg1$1@smc.vnet.net>

Well, i'm going to try to clarify it a little, but, as I said, is not
posible to paste the complete code; the equations are just too big. I
also made a mistake writing the last email.

So, for example,

{eqns, cond}={f1'[t]==a11*f1[t]+a12*f2[t]+...+a1N*fN[t],...,
fN'[t]==aN1*f1[t]+aN2*f2[t]+...+aNN*fN[t], f1[0]==t01,...,fN[0]==t0N},

and

f={f1,f2,...,fN}.

If Something is, say 1, then

sol[[1, 1]]:
f1[t]->InterpolatingFunction[{{0.`,1200.`}},"<>"][t]

and  sol[[1, 1, 2]] is just InterpolatingFunction[{{0.`,1200.`}},"<>"][t].


So, with

sol=NDSolve[{eqns, cond},f,{t,0,1200}][[1]];
a[t_]=sol[[1, 1, 2]]
b[t_]=sol[[1, 2, 2]]

i'm just extracting the solution for two of my variables, f1 and f2.

Plot "a" and "b",


Plot[{a[t], b[t]},{t,0,1200}],

was fast; however this:

Plot[{Evaluate[f1[t]/.sol], Evaluate[f2[t]/.sol]},{t,0,1200}],

was, somehow, imposible.

2011/7/11 DrMajorBob <btreat1 at austin.rr.com>:
>> and that was it. However I don't understand this. Was the problem the
>> "size" and "amount" of interpolated functions?
>
> I don't understand it either. The two methods seem equivalent, but this code
>
>> sol=NDSolve[{eqns, cond},f,{t,0,1200}][[1]];
>> a=sol[[1, Something, 2]]
>> b=sol[[1, Something+1, 2]]
>
> suggests that you're solving for one function f in the first line, and YET,
> you're extracting two solutions a and b in the next two lines. That's not
> possible, so you're not showing us the code you actually used. (We know that
> anyway, since "eqns", "cond", and "Something" are undefined.)
>
> I suspect in the real code, the two methods that seem equivalent are NOT
> equivalent at all.
>
> Bobby
>
> On Mon, 11 Jul 2011 05:58:03 -0500, Iv=E1n Lazaro <gaminster at gmail.com> wrote:
>
>> Hi!
>>
>> Yes, I tried
>>
>>  sol=NDSolve[{eqns, cond},f,{t,0,1200}][[1]];
>>  Plot[Evaluate[f[t]/.sol],{t,0,1200}],
>>
>> but that was a pain. Thanks to Bobby I managed to solve my speed problem:
>>
>> Instead of
>>
>> sol=NDSolve[{eqns, cond},f,{t,0,1200}][[1]];
>> Plot[Evaluate[f[t]/.sol],{t,0,1200}],
>>
>> I selected the specific solutions I needed, and Set them to a variable
>> that then I plot:
>>
>>
>>
>> sol=NDSolve[{eqns, cond},f,{t,0,1200}][[1]];
>> a=sol[[1, Something, 2]]
>> b=sol[[1, Something+1, 2]]
>>
>> Plot[{a[t],b[t]}],{t,0,1200}],
>>
>> and that was it. However I don't understand this. Was the problem the
>> "size" and "amount" of interpolated functions?
>>
>
>
> --
> DrMajorBob at yahoo.com
>


  • Prev by Date: Re: How to write a "proper" math document
  • Next by Date: Re: MultinormalDistribution Question
  • Previous by thread: Re: Incredible slow Plot
  • Next by thread: Re: Incredible slow Plot