MathGroup Archive 2000

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

Search the Archive

Re: How can I assign variables

  • To: mathgroup at smc.vnet.net
  • Subject: [mg22586] Re: How can I assign variables
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Sun, 12 Mar 2000 22:55:31 -0500 (EST)
  • References: <8aeju5$3c4@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Mark,

1. I wonder if some typos crept in? I'll use the following - the discussion
proceeds irresepective of the cahnge.

soln = DSolve[B'[t] == (10 - B[t]) B[t], B[t], t]

        {{B[t] -> (10*E^(10*t))/(E^(10*t) - E^C[1])}}

B[t_] = B[t] /. soln[[1]]

        (10*E^(10*t))/(E^(10*t) - E^C[1])

B[s]

(10*E^(10*s))/(E^(10*s) - E^C[1])

Clear[B]

B[t] = B[t] /. soln[[1]]

        (10*E^(10*t))/(E^(10*t) - E^C[1])

2. Now, why do we need [[1]]?.

It's because there may be more than one "solution":

Clear[B]

soln2 = DSolve[B'[t]^2 == (10 - B[t]) B[t], B[t], t]

        {{B[t] -> -5*(-1 - Sin[t - C[1]])},
          {B[t] -> -5*(-1 + Sin[t - C[1]])}}

Plot[Evaluate[B[t] /. soln2 /. C[1] -> 1], {t, 0, 2},
  PlotStyle -> {Hue[0], Hue[.7]}]

3. Problems with storing solution in B[t]

If B is specific to this equation and the equation has only one solution
then this is OK, but  if we have several equations or several solutions then
it may be better to use other names.
We had to clear B at the start of 2, and if we want to use the solution
functions it might be better to use the following ( which also lets us use
the constants conveniently)

{fn1[t_, c_], fn2[t_, c_]} =
  B[t] /. soln2 /. C[1] -> c

{-5*(-1 + Sin[c - t]), -5*(-1 - Sin[c - t])}

Plot[ {fn1[t, 1], fn2[t, 0]}, {t, 0, 2},
  PlotStyle -> {Hue[0], Hue[.7]}]


Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565


"mark griggs" <markgriggs at sc.rr.com> wrote in message
news:8aeju5$3c4 at smc.vnet.net...
> How can I do this
>
> If I evaluate the following
>    DSolve[B'[t]==(10-B-T) B,B[t],t]   I get {{B[t]-> t(10B -B^2 -Bt)
> +C[1]}}
>
> what must I do to have the answer on the right of the -> actually stored
> in B[t] so that I may use it in further calculations without having to
> cut and paste.
>
> regards
>
> mark G
> mathematica 4.0 Linux
> Mandrake 7.0
>
>
> --
> Heisenberg may have slept here
> ------------------------------
>



  • Prev by Date: external files and strings
  • Next by Date: Re: Option Inspector
  • Previous by thread: Re: How can I assign variables
  • Next by thread: Fonts problem