MathGroup Archive 2002

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

Search the Archive

Re: Using rules from Solve

  • To: mathgroup at smc.vnet.net
  • Subject: [mg33698] Re: Using rules from Solve
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Mon, 8 Apr 2002 03:04:27 -0400 (EDT)
  • References: <a8m2vj$oag$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

"postman" <post_12 at hotmail.com> wrote in message
news:a8m2vj$oag$1 at smc.vnet.net...
> Hey All:
> I appreciate any help with the following. I have a working solution,
> but don't understand why my first attempt failed. I'm using Solve to
> generate solutions to a set of simultaneous equations (the mass action
> equations in chemistry), then want to use the resulting solutions to
> calculate numerical values for specific values of the parameters.
>
> KdEqn={Kd==R*L/RL, RT=RL+R}
>
> Solve[KdEqn,RL,{RF}] gives me a rule,
>
> {{RL->L*RT/(Kd+L)}}
>
> and Replace[RL,Flatten[Solve[KdEqn,RL,{RF}]]] gives an expression
>
> L*RT/(Kd+L)
>
> that looks like what I would type on the right hand side of a
> function:
>
> Rl[L_] := L*RT/(Kd+L)
>
> The problem is that
>
> Rl[L_] := Replace[RL,Flatten[Solve[KdEqn,RP]{Rf}]]
>
> fails; Rl[1] does not substitute the value "1" for "L". However,
>
> Rl[L_] = Replace[RL,Flatten[Solve[KdEqn,RP]{Rf}]]
>
> works as I want. Why does the := construct fail here?
>
> Thanks for any help!
>

It seems that Rf should be R, but the crucial point is that with

Rl[L_] := Replace[RL,Flatten[Solve[KdEqn,RP]{R}]]

the rule is stored with the right side unevaluated, whereas with

Rl[L_] = Replace[RL,Flatten[Solve[KdEqn,RP]{R}]]

the right side is evaluated before the rule is stored.

This is the main difference between SetDelayed (:=) and Set (=)

--
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






  • Prev by Date: Re: [Q]: huge number, ciphers after decimal point?
  • Next by Date: Re: Optional
  • Previous by thread: Using rules from Solve
  • Next by thread: RE: Using rules from Solve