Ask Your Question
2

Equality test of symbolic expressions

asked 2018-03-25 21:44:56 +0100

joaoff gravatar image

I'm confused about the equality test of symbolic expressions. I saw the recently asked question https://ask.sagemath.org/question/417... and, coincidently, I read something similar on the first page of the second chapter of this book http://dl.lateralis.org/public/sagebo.... It says that Sage evaluates the following expressions as below,

sage: bool(arctan(1+abs(x)) == pi/2 - arctan(1/(1+abs(x))))
False
sage: bool(arctan(sqrt(2)) == pi/2 - arctan(1/sqrt(2)))
True

In Wikipedia (https://en.wikipedia.org/wiki/List_of...), we can verify the corresponding trigonometric identity.

$ arctan\left(x\right) + arctan\left(\frac{1}{x}\right) = \frac{\pi}{2}, \; if \; x>0$

and

$ arctan\left(x\right) + arctan\left(\frac{1}{x}\right) = -\frac{\pi}{2}, \; if \; x<0$

The above evaluation works as is in the version I am using.

sage: version()
'SageMath version 7.5.1, Release Date: 2017-01-15'

However, in Sage Math Cell or Cocalc ('SageMath version 8.1, Release Date: 2017-12-07') both tests evaluate to False.

Mathematica is not able to evaluate any of the expressions and return the entire equality test without evaluation.

Questions:

1) I understand that both tests should evaluate to True, am I right? If so, and as Sage 7.5.1 can verify the second equality, why it can't verify the first?

2) Why the newer version of Sage cannot verify the second equation anymore?

3) Differently from Mathematica, that returns True if both expressions are numerically equal, False otherwise and returns the test unevaluated if it cannot establish the equality, Sage returns True if it can prove that the difference between both expressions is zero and False otherwise. Is this correct?

edit retag flag offensive close merge delete

Comments

1

1) See my (partial) answer below.

2) Nice question. If you have a Sage development tree, you might try to bisect it...

3) is correct for Sage. I dunno about Mathematica.

Note that the introduction in Sage of "unknown" answers to boolean questions, available in Maxima (see ?maxima.is), has been discussed ad nauseam without decision for implementation.

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2018-03-26 15:39:19 +0100 )edit

In item 2, I haven't understood what you mean. I don't have much experience in software development. In item 3, I took a while to accept the way Sage works, but now, it seems very logical to me. Thanks again!

joaoff gravatar imagejoaoff ( 2018-03-26 21:17:44 +0100 )edit

sage is not always able to simplify the expressions into what you need, sometimes you need to direct it towards a specific type of simplification, expansion, etc. which will lead to your desired expression that is ultimately equal to zero.

DanialBagh gravatar imageDanialBagh ( 2018-03-30 08:13:16 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2018-03-26 15:34:46 +0100

Emmanuel Charpentier gravatar image

Note that, for Sage :

sage: bool(tan(arctan(x))==x)
True
sage: bool(arctan(tan(x))==x)
False

(Indeed, the first expression is defined (and True) for all $x\in\mathbb{R}$, whereas the second is defined for $x\neq\frac{2k+1}{2}\pi,~k\in\mathbb{Z}$, and True only for $x \in \left]-\frac{\pi}{2},~\frac{\pi}{2}\right[$).

Note also that, for Sage :

sage: tan(pi/2-x).trig_expand()
cot(x)
sage: tan(x-pi/2).trig_expand()
-cot(x)
sage: bool(cot(x)==1/tan(x))
True

which allow to retrieve your equalities (assuming that the domain choosen for $\arctan$ is indeed $\left]-\frac{\pi}{2},~\frac{\pi}{2}\right[$).

edit flag offensive delete link more

Comments

I imagined that the interval where arctan is defined should have something to do with the issue, but I was not sure. Thanks a lot, your answer is very clear.

joaoff gravatar imagejoaoff ( 2018-03-26 21:08:33 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2018-03-25 21:44:56 +0100

Seen: 2,594 times

Last updated: Mar 26 '18