15
$\begingroup$

When I input:

FullSimplify[(1 - a^2)/b^2, a^2 + b^2 == 1]   

the result is the ideal answer 1;

However,if I input:

FullSimplify[(1 - b^2)/a^2, a^2 + b^2 == 1]   

the result is (1 - b^2)/a^2, instead of the ideal answer 1. How to get the correct answer 1?

$\endgroup$
5
  • $\begingroup$ Since you are using an equality, how about using ReplaceAll; FullSimplify[((1 - a^2)/b^2) /. a -> Sqrt[1 - b^2]] ? $\endgroup$
    – Sumit
    Commented Nov 7, 2016 at 12:57
  • 1
    $\begingroup$ It seems like that we should need manual deduction to get the specific variable expressions in advance... $\endgroup$
    – dabuyang
    Commented Nov 7, 2016 at 14:41
  • $\begingroup$ Somewhat related (notice those links in the comments): mathematica.stackexchange.com/q/25182/1871 $\endgroup$
    – xzczd
    Commented Nov 8, 2016 at 8:22
  • 1
    $\begingroup$ In the Possible Issues item of the Documentation for FullSimplify, it is explicitly stated that Results of simplification may depend on the names of symbols. $\endgroup$ Commented Nov 11, 2016 at 2:41
  • $\begingroup$ @AlexanderZeng Side note: this "possible issue" seems to be added recently, it's not included in the document of v9.0.1…… $\endgroup$
    – xzczd
    Commented Dec 3, 2016 at 7:45

1 Answer 1

9
$\begingroup$
Simplify[(1 - a^2)/b^2, a^2 + b^2 == 1]

(*  1  *)

Simplify[(1 - b^2)/a^2, a^2 + b^2 == 1]

(*  (1 - b^2)/a^2  *)

The result returned from some of Mathematica's internal algorithm's can sometimes be affected by the canonical order of the variables involved. Your problem is an example.

To reverse the canonical order

switchOrder = {a -> d, b -> c};

soln = Simplify @@ ({(1 - b^2)/a^2, a^2 + b^2 == 1} /. switchOrder)

(*  1  *)

Although in this case it is not necessary to return to the original variables, this would generally be required. To return to the original variables

soln /. (Reverse /@ switchOrder)

(*  1  *)

EDIT: See here for another example

$\endgroup$
2
  • 1
    $\begingroup$ Is there any experience about when the canonical order seems to be important? Of course, in this case it is easy to spot, but it seems that one would "always" need to switch orders and compare results of Simplify if it doesn't return what one wants...? $\endgroup$
    – Lukas
    Commented Nov 8, 2016 at 7:59
  • 1
    $\begingroup$ @Lukas - undoubtedly, this is not done automatically since there would be a performance cost and would generally not help or not change the form of the result enough to be worth the cost--likewise for manual application. Consequently, it should only be investigated if there is reason to believe that a more preferred form should exist or one is building a component that needs to be highly optimized & it is worth the effort to ensure that you have discovered the highest performance form. Note that the problem compounds with the number of variables--we were only dealing with two variables here. $\endgroup$
    – Bob Hanlon
    Commented Nov 8, 2016 at 15:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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