Ask Your Question
0

Evaluation of triangle inequality

asked 2019-12-20 19:27:45 +0100

Minhtri gravatar image

updated 2020-10-11 23:16:49 +0100

slelievre gravatar image

I wrote the following code:

x = var('x')
assume(x,'real')
y = var('y')
assume(y,'real')
z = var('z')
assume(z,'real')

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

Then I run it:

sage: bool(expr)
False

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
2

answered 2019-12-21 11:37:23 +0100

Emmanuel Charpentier gravatar image

updated 2019-12-21 11:44:07 +0100

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));
....: 
done
unknown

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).

HTH,

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

Stats

Asked: 2019-12-20 19:27:45 +0100

Seen: 693 times

Last updated: Oct 11 '20