How can I tell Mathematica that I want to simplify all expressions like
Sqrt[x^2] as x, whithout taking into account that x is or not a
positive real number?
Thank you very much
--
----
Francisco Javier García Capitán
http://garciacapitan.auna.com
I think Refine[Sqrt[x^2],x>0]
is what you need.
Bye,
Ruth
Simplify[Sqrt[x^2], x > 0]
Regards
Jens
"Francisco Javier" <pac...@ctv.es> schrieb im
Newsbeitrag news:difreg$fg6$1...@smc.vnet.net...
Dear F.Jaccard and Ruth for your answers, but what I really mean has
not a such simple solution.
I want to "teach" to Mathematica that in next calculations Sqrt[x^2] is
equivalent to x,
I have tried
Unprotect[Sqrt];
Sqrt[(x_)^2] := x;
This seems works fine then with calculations like
Sqrt[y^2]
y
but it fails with
Sqrt[x^2 y^4]
or even with
Sqrt[x^2 y^4]
Any ideas?
output/.{Sqrt[a_^2]->a}
As far as I can tell, this will just pattern-match without regard as
to the positiveness or even realness of the argument a.
Cheers,
C.O.
Francisco Javier wrote:
>Dear all, I am new in this group
>
>How can I tell Mathematica that I want to simplify all expressions like
>Sqrt[x^2] as x, whithout taking into account that x is or not a
>positive real number?
>
>Thank you very much
>
>
>
--
|=====
| Curtis Osterhoudt
| gard...@mail.wsu.edu
| PGP Key ID: 0x235FDED1
| Please avoid sending me Word or PowerPoint attachments.
| http://www.gnu.org/philosophy/no-word-attachments.html
|=====
>How can I tell Mathematica that I want to simplify all expressions
>like Sqrt[x^2] as x, whithout taking into account that x is or not
>a positive real number?
PowerExpand will do what you want, i.e.,
In[20]:= PowerExpand[Sqrt[x^2]]
Out[20]= x
This tranformation is not included amoung the tranformations applied by Simplify or FullSimplify since it is not valid for all possible values of x.
--
To reply via email subtract one hundred and four
Clear[mySqrt];
mySqrt[a_.*x_^2]:=mySqrt[a]*x;
mySqrt[a_?AtomQ]:=Sqrt[a];
convertSqrt=Power[x_,Rational[1,2]]:>mySqrt[x];
{Sqrt[x^2],Sqrt[a*x^2],Sqrt[Pi*x^2*y^2]}/.convertSqrt
{x, Sqrt[a]*x, Sqrt[Pi]*x*y}
Bob Hanlon
>
> From: "Francisco Javier" <pac...@ctv.es>
> Date: 2005/10/12 Wed AM 01:42:23 EDT
> Subject: Re: sqrt(x^2) = x
>
> Francisco Javier a formulé ce martes :
> > Dear all, I am new in this group
> >
> > How can I tell Mathematica that I want to simplify all expressions like
> > Sqrt[x^2] as x, whithout taking into account that x is or not a
> > positive real number?
> >
Clear[mySqrt];
mySqrt[a_.*x_^n_?EvenQ]:=
mySqrt[a]*x^(n/2);
mySqrt[a_.*x_^n_?OddQ]:=
mySqrt[a*x]*x^((n-1)/2);
mySqrt[a_*b_]:=
mySqrt[a]*mySqrt[b];
mySqrt[a_?AtomQ]:=
Sqrt[a];
convertSqrt=
Power[x_,Rational[1,2]]:>mySqrt[x];
{Sqrt[x^2],Sqrt[a*x^2],Sqrt[a*x^5],Sqrt[a*Pi*
x^6],Sqrt[Pi*x^5*y^6]}/.convertSqrt
{x, Sqrt[a]*x, Sqrt[a]*x^(5/2), Sqrt[a]*Sqrt[Pi]*x^3,
Sqrt[Pi]*x^(5/2)*y^3}
Bob Hanlon