I have the following expression in Mathematica
-((E^(2 - 2 Sqrt[(x[1] - x[2])^2]) (x[1] - x[2]))/Sqrt[(x[1] -
x[2])^2])
I want to replace anything of the form Sqrt[t^2] to t. I tried
-((E^(2 - 2 Sqrt[(x[1] - x[2])^2]) (x[1] - x[2]))/
Sqrt[(x[1] - x[2])^2]) /. Sqrt[(t_)^2] -> t
But it just does the changes in the numerator and not in the denominator. What is that I am doing wrong here? Thanks in advance! -dbm
FullFormyou'll see that you need{Sqrt[(t_)^2] -> t, 1/Sqrt[t_^2] -> 1/t}. – b.gates.you.know.what Nov 05 '13 at 17:09FullForm[]when a replacement doesn't work – Dr. belisarius Nov 05 '13 at 17:11FullForm[Sqrt[x]] == Power[x, Rational[1,2]]whileFullForm[1/Sqrt[x]] == Power[x, Rational[-1,2]]and therefore your pattern will not match. – b.gates.you.know.what Nov 05 '13 at 17:58