Re: 'Changing' parameters in an expression

• To: mathgroup at smc.vnet.net
• Subject: [mg60579] Re: [mg60528] 'Changing' parameters in an expression
• From: Bob Hanlon <hanlonr at cox.net>
• Date: Wed, 21 Sep 2005 03:20:12 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```eqn=x'[t]==x[t](x[t]-a);

soln=DSolve[{eqn, x[0]==x0},x[t],t][[1,1]]//FullSimplify

x[t] -> (a*x0)/(E^(a*t)*(a - x0) + x0)

eqn/.{soln ,D[soln,t]}//Simplify

True

You need an initial condition (x0) in order to plot. Assume x0=1/4 (note that
x0 must be less than a to avoid a pole)

funcs={x[t],eqn[[2]]}/.soln/.
{a->1/2,x0->1/4}//Simplify

{1/(2 + 2*E^(t/2)), -(E^(t/2)/(4*(1 + E^(t/2))^2))}

Plot[Evaluate[funcs],{t,0,6},
PlotStyle->{Blue,Red}];

Bob Hanlon

>
> From: "Matt" <anonmous69 at netscape.net>
To: mathgroup at smc.vnet.net
> Date: 2005/09/19 Mon AM 04:45:45 EDT
> Subject: [mg60579] [mg60528] 'Changing' parameters in an expression
>
> Hello,
>   What follows (at the end) worked for me, however, I'm wondering if
> it's the 'right' approach or not.  What I mean by 'right' is this:  my
> eventual approach worked, but there may be another approach that is
> more efficient and demonstrates a more wide ranging principal in using
> Mathematica, and hence would be applicable in many situations.
>
> I started off with this:
> eqn = x'[t] == x[t](x[t] - a);
>
> (I am using eqn as the first argument to DSolve, which is why it
> appears as it does.)
>
> I wanted to plot the rhs of eqn with 'a' having a value of 1/2, so
> first I tried this:
> Plot[eqn[[2]] /. a->1/2, {t, 0, 6}];
>
> That didn't work as I got these types of errors:
> Plot::plnr : eqn[[2]] /. a -> 1/2 is not a machine-size real number at
> t = ....
>
> over and over again.
>
> I tried a few other rules with essentially the same results and then I
> tried this:
> Plot[eqn[[2]] /. {a->1/2, x[t]->x}, {x, 0, 6}];
>
> Which worked for me.  I'm sure it has something to do with what I'm
> asking Plot to work with.  It just seems strange to me that DSolve will
> work with eqn, but Plot does not.
>
> Thanks for any help,
>
> Matt
>
>

```

• Prev by Date: Re: "layering" 2d plots
• Next by Date: Re: "layering" 2d plots
• Previous by thread: Re: 'Changing' parameters in an expression
• Next by thread: Re: 'Changing' parameters in an expression