Ask Your Question
1

New to sage, but it seems wrong.

asked 2017-05-18 17:20:41 +0100

nowad gravatar image

I am doing some calculations and I was just check on some simplifications and came across a discrepancy. Logically, this does not make any sense to me, so I must assume this is something weird with sage that I am not aware of. I put the problem in a new worksheet to check that I didn't have some variable assigned to a different value elsewhere by accident.

[I apologize for the code and the formatting to follow, I can't upload an image since I am a new user]

in: l=arccosh(-8sqrt(2)(sqrt(2) - 2)/((2^(3/4)sqrt(sqrt(2) + 2) + sqrt(2) + 2)^2(2sqrt(2)/(2^(3/4)sqrt(sqrt(2) + 2) + sqrt(2) + 2) - 4/(2^(3/4)sqrt(sqrt(2) + 2) + sqrt(2) + 2))(sqrt(2)/(2^(3/4)sqrt(sqrt(2) + 2) + sqrt(2) + 2) - 2/(2^(3/4)sqrt(sqrt(2) + 2) + sqrt(2) + 2))) + 1)

in: l


out:"arccosh(-4sqrt(2)(sqrt(2) - 2)/((2^(3/4)sqrt(sqrt(2) + 2) + sqrt(2) + 2)^2(sqrt(2)/(2^(3/4)sqrt(sqrt(2) + 2) + sqrt(2) + 2) - 2/(2^(3/4)sqrt(sqrt(2) + 2) + sqrt(2) + 2))^2) + 1)


in: n=cosh(l)

in: n


out:"-4sqrt(2)(sqrt(2) - 2)/((2^(3/4)sqrt(sqrt(2) + 2) + sqrt(2) + 2)^2(sqrt(2)/(2^(3/4)sqrt(sqrt(2) + 2) + sqrt(2) + 2) - 2/(2^(3/4)sqrt(sqrt(2) + 2) + sqrt(2) + 2))^2) + 1


in: bool(n==5+4*sqrt(2))


out:"True"


in: bool(l==arccosh(n))


out:"True"


in: bool(l==arccosh(5+4*sqrt(2)))


out:"False"

So, what this says, I have some number l, which is arccosh of an ugly string, and I name the ugly string n. Turns out n simplifies to 5+4sqrt(2), which I check in the middle of the code with bool. And sage agrees, and I check that l is still arccosh of n, and sage agrees. BUT, then sage says that l is NOT arccosh of 5+4sqrt(2), which we see at the end of my code.

I don't understand how this could be giving me seemingly contradictory statements. Any help would be very appreciated.

edit retag flag offensive close merge delete

Comments

2

As it turns out, bool only returns True when Sage knows the answer is true, and otherwise returns False - even if it turns out it is true. So apparently whatever algorithm is checking the individual parts isn't able to check the last statement properly. I'm not sure if that happens in Pynac or Maxima, but hopefully someone will be able to give you more details; however, that is the essence.

kcrisman gravatar imagekcrisman ( 2017-05-18 17:45:04 +0100 )edit
1

There is nothing wrong in being new to sage. (I have very often the same feeling.)

dan_fulea gravatar imagedan_fulea ( 2017-05-18 22:02:00 +0100 )edit

And Sage is so big that even those of us who are now superannuated in Sage terms feel new as soon as we step into an unfamiliar corner of it!

kcrisman gravatar imagekcrisman ( 2017-05-19 02:44:52 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2017-05-18 21:59:49 +0100

dan_fulea gravatar image

The following code reproduces the issue.

s0 = 2^(3/4) * sqrt( sqrt(2) + 2 ) + sqrt(2) + 2

s = ( 1 - 8*sqrt(2)*(sqrt(2) - 2)
      /
      ( s0^2 * (2*sqrt(2)/s0 - 4/s0) * (sqrt(2)/s0 - 2/s0) ) )

S = ( 1 - 8*sqrt(2)*(sqrt(2) - 2)
      /
      ( s0^2 * (2*sqrt(2)-4)/s0 * (sqrt(2)-2)/s0 ) )


l = arccosh( s )
n =    cosh( l )

L = arccosh( S )
N =    cosh( L )

bool( n == 5+4*sqrt(2)  )
bool( l == arccosh( n ) )
bool( l == arccosh( 5+4*sqrt(2) ) )

bool( N == 5+4*sqrt(2)  )
bool( L == arccosh( N ) )
bool( L == arccosh( 5+4*sqrt(2) ) )

I'm just using a new variable s0 for the repeatedly used denominator. In the posted code, there is some expression (2*sqrt(2)/s0 - 4/s0) that can be humanly immediately rephrased as (2*sqrt(2)-4)/s0. Same for the half values. But let us make distinction between the two expressions. So we have two distinct expressions s and S. We propagate the change for l and n, getting capitalized variables. Running the boolean evaluations against N and L we have (in the sage interpreter, started from the linux console):

sage: bool( N == 5+4*sqrt(2)  )
....: bool( L == arccosh( N ) )
....: bool( L == arccosh( 5+4*sqrt(2) ) )
....: 
True
True
True

Doing the same job for the lower case variables...

sage: bool( n == 5+4*sqrt(2)  )
....: bool( l == arccosh( n ) )
....: bool( l == arccosh( 5+4*sqrt(2) ) )
....: 
True
True
False

As said in the above comment to the post (and in so many other places), the last False means that the "standard program/plan" started by sage to test equality did not lead to "the same". The False should be considered as a "can not prove it is true by doing the usual check operations". We can of course help sage simplify one more step...

sage: bool( l.simplify_full() == arccosh( 5+4*sqrt(2) ) )
True
edit flag offensive delete link more

Comments

The small L is a bad name for a variable. (Even if we tolerate with no hesitation one letter python variables.) Even with glasses, it is hard to not see the one first in it. (Only the big O is the alternative to have a similar bad situation, but fortunately we have a "function" with this name in mathematics - and thus also in sage, this is generally considered ok, so the small L wins the first place for a bad notation.)

dan_fulea gravatar imagedan_fulea ( 2017-05-18 22:11:08 +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

1 follower

Stats

Asked: 2017-05-18 17:20:41 +0100

Seen: 577 times

Last updated: May 18 '17