Re: Re: plot thousands(?) of trajectories in single graph.

• To: mathgroup at smc.vnet.net
• Subject: [mg50526] Re: [mg50494] Re: plot thousands(?) of trajectories in single graph.
• From: DrBob <drbob at bigfoot.com>
• Date: Thu, 9 Sep 2004 05:17:47 -0400 (EDT)
• References: <chk0es\$so\$1@smc.vnet.net> <200409080908.FAA08363@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Very nice, but I'd block y, g, and omega to avoid surprises, as follows:

DoRandomSolution[i_Integer] := Block[{\$DisplayFunction = Identity, sol, y,
g, omega}, Table[sol = NDSolve[{y''[t] - g*y'[t] + (1 + Cos[omega*t])*y[
t] == 0, y[0] == Random[], y'[0] ==
Random[]} /. {g -> Random[],
omega -> 2Pi*Random[]}, {y[t]}, {t, 0, 6Pi}];
Plot[Evaluate[y[t] /. sol[[1]]], {t, 0, 2Pi}], {i}]]

Bobby

On Wed, 8 Sep 2004 05:08:27 -0400 (EDT), Jens-Peer Kuska <kuska at informatik.uni-leipzig.de> wrote:

> Hi,
>
> DoRandomSolution[i_Integer] :=
>   Block[{\$DisplayFunction = Identity, sol},
>     Table[sol = NDSolve[{
>               y''[t] - g*y'[t] + (1 + Cos[omega*t])*y[t] == 0,
>               y[0] == Random[],
>               y'[0] == Random[]} /.
>             {g -> Random[],
>               omega -> 2Pi*Random[]}, {y[t]}, {t, 0, 6Pi}];
>       Plot[Evaluate[y[t] /. sol[[1]]], {t, 0, 2Pi}], {i}]
>     ]
>
> ss = DoRandomSolution[4000];
> Show[ss]
>
> Regards
>   Jens
>
>
> sean kim wrote:
>>
>> hello group,
>>
>> I have a routein that solves a system of odes over a
>> parameter space thousands of times while randomly
>> varying the values.
>>
>> What I would like to do is take a variable and the
>> resulting solutions(however many routine has generated
>> over the course of evaluation) and plot them on single
>> graph.
>>
>> So you will get rather messy graph, but nonetheless
>> shows possible trajectories given system can yield.
>>
>> How do I go about doing this?
>>
>> I thought i could save the interpolating functions and
>> then evaluate thousands at the end of a routine and
>> show together. But How do I save the interpolating
>> function?
>>
>> or do I plot with inside the module with
>> DisplayFunction-> Identity and then save the plot and
>> DisplayTogether the thousands of graphs at the end of
>> the routine.
>>
>> if doing thousands isn't possible, is it possible to
>> show hundreds of trajectories?
>>
>> thanks in advance for any insights.
>>
>> sean
>>
>> code below is a example skeletal code for running
>> hundred random solutions of an ode system.
>>
>> Do[
>> Module[{},
>> k1 = Random[Real, {1/10, 5/10}];
>> k2 = Random[Real, {1/20, 5/20}];
>> ndsolution =
>> NDSolve[{a'[t] == -k1  a[t] x[t], b'[t] == -k2 b[t]
>> y[t], x'[t] == -k1 a[t] x[t] + k2 b[t] y[t], y'[t] ==
>> k1 a[t] x[t] - k2  b[t] y[t], a[0] == 1, b[0] == 1,
>> x[0] == 1, y[0] == 0},{a, b, x, y}, {t, 0, 250}][[1]];
>> Plot[Evaluate[{a[t], b[t], x[t], y[t]} /. ndsolution],
>> {t, 0, 250}, PlotRange -> All, PlotStyle ->
>> {{AbsoluteThickness[2], RGBColor[0, 0, 0]},
>> {AbsoluteThickness[2], RGBColor[.7, 0, 0]},
>> {AbsoluteThickness[2], RGBColor[0, .7, 0]},
>> {AbsoluteThickness[2], RGBColor[0, 0, .7]}}, Axes ->
>> False, Frame -> True, PlotLabel -> StyleForm[A
>> StyleForm[" B", FontColor -> RGBColor[.7, 0, 0]]
>> StyleForm[" X", FontColor -> RGBColor[0, .7,
>> 0]]StyleForm[" Y", FontColor -> RGBColor[0, 0, .7]],
>> FontFamily -> "Helvetica", FontWeight -> "Bold"]];
>> ]
>> ,{i, 100}]
>>
>>
>> _______________________________
>> Do you Yahoo!?
>> Win 1 of 4,000 free domain names from Yahoo! Enter now.
>> http://promotions.yahoo.com/goldrush
>
>
>

--
DrBob at bigfoot.com
www.eclecticdreams.net

```

• Prev by Date: Re: How to solve a simple Trig cofunction?
• Next by Date: Re: Exact real numbers
• Previous by thread: Re: plot thousands(?) of trajectories in single graph.
• Next by thread: Re: plot thousands(?) of trajectories in single graph.