using rules for square roots
- To: mathgroup at smc.vnet.net
- Subject: [mg110257] using rules for square roots
- From: Kent Holing <KHO at statoil.com>
- Date: Thu, 10 Jun 2010 08:10:04 -0400 (EDT)
Using the Mathematica session
str={Sqrt[a],Sqrt[b^2],Sqrt[c^3],Sqrt[d^4],Sqrt[e^5]};
g[x_,n_]:=Module[{m=Quotient[n,2]},If[EvenQ[n],x^m,x^m Sqrt[x]]];
rule1=Sqrt[x_ y_]->Sqrt[x] Sqrt[y];
rule2=Sqrt[x_^2]->x;
rule=Sqrt[x_^n_]->x^Quotient[n,2] Sqrt[x^Mod[n,2]];
rule0=Sqrt[x_^n_]->g[x,n];
Now, str/.rule gives the "correct" answer
{Sqrt[a],b,c^3/2,d^2,e^5/2}.
But why does not rule0 work?
str/.rule returns
{Sqrt[a],b^3/2,c^3/2,d^5/2,e^5/2}.
I would also like that rule (and rule0) should return say
e^5/2 as e^2 Sqrt[e]. How can this be accomplished?
Kent