Ask Your Question
0

Evaluation of triangle inequality

asked 5 years ago

Minhtri gravatar image

updated 4 years ago

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"?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
2

answered 5 years ago

Emmanuel Charpentier gravatar image

updated 5 years ago

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,

Preview: (hide)
link

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: 5 years ago

Seen: 777 times

Last updated: Oct 11 '20