1
$\begingroup$

I found an entry of a matrix from two different methods using mathematica. Which are given as;

g/(Sqrt[2] Sqrt[1 + g^2 - Sqrt[1 + g^2]])

and

1/Sqrt[2 + (2 - 2 Sqrt[1 + g^2])/g^2]. 

Logically these expression should be same, and they simplify to same result when i do it on paper. But when i plot these expressions for {g,-5,5}, it gives different plots on mathematica. What is happening?

$\endgroup$
  • $\begingroup$ Sqrt[g^2] is not equal to g, when g is negative. $\endgroup$ – bbgodfrey Jan 18 '15 at 16:44
  • $\begingroup$ @bbgodfrey, but these should reduce to single simplified form? $\endgroup$ – Usman Jan 18 '15 at 17:07
  • $\begingroup$ @Usman All you need you could find here: Simplifying expressions with square roots $\endgroup$ – Artes Jan 18 '15 at 17:15
  • $\begingroup$ @Usman, No. Sqrt[g^2] is a Mathematica function equal to g for g > 0 and to -g for g < 0. To go from your first expression to your second involves multiplying the first function by Sqrt[g^2]/g, which is not equal to one for negative g. $\endgroup$ – bbgodfrey Jan 18 '15 at 17:18
  • $\begingroup$ The two plots are exactly the same for g>0 but not for g<0, as per bbgodfrey's comment. $\endgroup$ – Stelios Jan 18 '15 at 17:21
2
$\begingroup$

These are two simplifications of the same second expression with different ConplexityFunction used:

 Simplify[1/Sqrt[2 + (2 - 2 Sqrt[1 + g^2])/g^2], g > 0]

Simplify[1/Sqrt[2 + (2 - 2 Sqrt[1 + g^2])/g^2], g > 0, 
 ComplexityFunction -> (StringLength[ToString[#]] &)]

yielding the following:

(*  1/Sqrt[2 + (2 - 2 Sqrt[1 + g^2])/g^2]  *)
(*  g/(Sqrt[2] Sqrt[1 + g^2 - Sqrt[1 + g^2]])  *)

Have fun!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.