Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • 1
    $\begingroup$ If you look at FullForm you'll see that you need {Sqrt[(t_)^2] -> t, 1/Sqrt[t_^2] -> 1/t}. $\endgroup$ Commented Nov 5, 2013 at 17:09
  • 2
    $\begingroup$ Yep, always use FullForm[] when a replacement doesn't work $\endgroup$ Commented Nov 5, 2013 at 17:11
  • $\begingroup$ It worked. But I don't understand the concept. Let's say, we want to replace E^(1 - x[1] + x[2]) to m[1,2]. Then the replacement doesn't change E^(2 - 2 (x[1] - x[2])) even thought it should be replaced by m[1,2]^2. $\endgroup$ Commented Nov 5, 2013 at 17:27
  • 1
    $\begingroup$ Because FullForm[Sqrt[x]] == Power[x, Rational[1,2]] while FullForm[1/Sqrt[x]] == Power[x, Rational[-1,2]] and therefore your pattern will not match. $\endgroup$ Commented Nov 5, 2013 at 17:58
  • $\begingroup$ This question has an answer here: Pitfalls. Related question: Why is ReplaceAll behaving like this? $\endgroup$ Commented Nov 5, 2013 at 19:02