Re: normalization and square roots
- To: mathgroup at smc.vnet.net
- Subject: [mg65770] Re: normalization and square roots
- From: "Chris Chiasson" <chris.chiasson at gmail.com>
- Date: Mon, 17 Apr 2006 02:28:08 -0400 (EDT)
- References: <e1su8g$c3t$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Ruth, I guess the problem happens because your delayed function definition for f does not evaluate the right hand side until the left hand pattern finds a suitabe expression. f[0,0.3,0.4] fits this pattern. Let's follow the evaluator: In[14]:= Trace[f[0,0.3,0.4],ReplaceAll[__],TraceBackward\[Rule]True, TraceForward\[Rule]True]//InputForm Out[14]//InputForm= {HoldForm[f[0, 0.3, 0.4]], HoldForm[1/(Sqrt[0.4] - Sqrt[0.3*(1 + 0)^3 + ol + 0.4]) /. ol -> myrule], HoldForm[(0.6324555320336759 - Sqrt[0.7 + ol])^ (-1) /. ol -> -om + (-1 + Sqrt[oro])^2 - oro], HoldForm[(0.6324555320336759 - Sqrt[0.7 - om + (-1 + Sqrt[oro])^2 - oro])^(-1)]} Notice that om and oro are replaced by 0.3 and 0.4 because they are symbols that match the named pattern objects om_ and oro_. myrule doesn't get replaced until its defition is called later, but the om and oro it is replaced with will not be substituted with 0.3 and 0.4. To make the substitution (or whatever it is supposed to be called) work, you could do two things. One, don't use a delayed function definition and make sure you define myrule before f. Like so (with a fresh kernel): myrule=-om+(-1+Sqrt[oro])^2-oro; f[x_,om_,oro_]=1/(Sqrt[oro]-Sqrt[om(1+x)^3+ol+oro])/.ol\[Rule]myrule f[0,0.3,0.4] Two, make myrule have DownValues that accept the symbols om and oro. Like so (with a fresh kernel): myrule[om_,oro_]=-om+(-1+Sqrt[oro])^2-oro; f[x_,om_,oro_]:=1/(Sqrt[oro]-Sqrt[om(1+x)^3+ol+oro])/.ol\[Rule]myrule[om,oro] f[0,0.3,0.4] You could also combine the two approaches. I would recommend approach one. Good Luck,