Ask Your Question

Evaluation of triangle inequality

asked 2019-12-20 12:27:45 -0500

Minhtri gravatar image

updated 2020-10-11 16:16:49 -0500

slelievre gravatar image

I wrote the following code:

x = var('x')
y = var('y')
z = var('z')

expr = abs(x-y)+abs(y-z) >= abs(x-z)

Then I run it:

sage: bool(expr)

The expression is obviously mathematically correct. How come Sage returns "False"?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2019-12-21 04:37:23 -0500

Emmanuel Charpentier gravatar image

updated 2019-12-21 04:44:07 -0500

Sage implements booleans,and answers to a"logical" query either by True, which means that Sage can compute an equality, or False, meaning that Sage cannot compute this equality. This does not mean that the result is false, only that Sage cannot prove it.

Mathematica does the same:

sage: %%mathematica
....: P = Abs[x - y] + Abs[y - z] >= Abs[x - z]
....: Assuming[x \[Element] Reals && y \[Element] Reals && z \[Element] Reals, Re
....: duce[P]]
        Abs[x - y] + Abs[y - z] >= Abs[x - z]
Out[3]= Abs[y - z] >= -Abs[x - y] + Abs[x - z]

Contrast this with Maxima:

sage: %%maxima
....: declare(x,real,y,real,z,real);
....: is(abs(x-y)+abs(y-z)>=abs(x-z));

Maxima implements "trinary logicals", i. e. a logical value can be true (i. e. the result can be computed true), false(the result can be cimputed false) or unknown (the result cannot be computed).


edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools


Asked: 2019-12-20 12:27:45 -0500

Seen: 176 times

Last updated: Oct 11