2
$\begingroup$

Let's say expr1= Sin x expr2 = e^x -e^-x/2j

Now we know they are the same mathematically, how will I come to know expr1=expr2 and they are the same?

Let's say I have these two equations and have code as these

FullSimplify[
  (ComplexExpand[#1, 
     TargetFunctions -> 
      {Re, Im}] & )[
   Abs[1 + (I*2*Pi)/
       (E^((-I)*2*Pi) - 
        E^((-I)*2*Pi*\[Lambda]))]^2]]

and then we have

(ComplexExpand[#1, 
    TargetFunctions -> 
     {Re, Im}] & )[
  Abs[1 + (I*2*Pi)/
      (E^((-I)*2*Pi) - 
       E^((-I)*2*Pi*\[Lambda]))]^2]

Both of them yield different answers but can I check whether they are the same or not?

$\endgroup$
8
  • 3
    $\begingroup$ Did you already try FullSimplify[expr1 == expr2]? (Incorporate variable assumptions with Assuming[] whenever applicable.) $\endgroup$ Jan 28, 2021 at 11:27
  • $\begingroup$ FullSimplify[expr1 == expr2] I did it now, but this gave expr-2's answer? How would I come to know both answers of expr1 == expr2 @J.M. $\endgroup$ Jan 28, 2021 at 11:33
  • 1
    $\begingroup$ Using your simpler example: FullSimplify[Sin[x] == (Exp[I x] - Exp[-I x])/(2 I)]. The True result implies that the equation is indeed true for all complex values of x. $\endgroup$ Jan 28, 2021 at 11:44
  • 1
    $\begingroup$ One other simple way is to simplify the difference between these two expressions. If they are identical, the simplification will return zero. $\endgroup$ Jan 28, 2021 at 13:08
  • 1
    $\begingroup$ @good_omen92 It gives True for me. Maybe try restarting your kernel? $\endgroup$ Jan 28, 2021 at 13:50

2 Answers 2

2
$\begingroup$

In many cases it is easier to show the difference is zero.

expr1 = FullSimplify[(ComplexExpand[#1, 
   TargetFunctions -> {Re, Im}] &)[
  Abs[1 + (I*2*Pi)/(E^((-I)*2*Pi) - E^((-I)*2*Pi*\[Lambda]))]^2]];

expr2 = (ComplexExpand[#1, TargetFunctions -> {Re, Im}] &)[
  Abs[1 + (I*2*Pi)/(E^((-I)*2*Pi) - E^((-I)*2*Pi*\[Lambda]))]^2];

expr1 - expr2 // Together // Simplify

(*   0   *)
$\endgroup$
1
  • $\begingroup$ I divide two-equations manually and solved the same equation by Mathematica, and let's say both are correct, FullSimplify[expr1 == expr2] yields a true? – Does that makes sense? @Akku $\endgroup$ Feb 4, 2021 at 10:18
6
$\begingroup$

There is no way to get a definitive answer to whether two expression are equivalent. It is an undecidable problem.

To let Mathematica do its best to find out, use PossibleZeroQ on their difference.

You can also use FullSimplify[expr1 == expr2, assumptions] which (a bit more usefully) can give True or False (meaning a certain result), or return the input (meaning "I don't know").

$\endgroup$
2
  • 1
    $\begingroup$ I was going to suggest PossibleZeroQ. Another thing to try is FindInstance[...!=0] to see if zero-equality can be disproved by counterexample. $\endgroup$ Jan 28, 2021 at 14:34
  • $\begingroup$ I divide two-equations manually and solved the same equation by Mathematica, and let's say both are correct, FullSimplify[expr1 == expr2] yields a true? $\endgroup$ Feb 4, 2021 at 9:02

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.