Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The irrational number e is not always understood #2455

Open
josd opened this issue Jul 21, 2024 · 8 comments
Open

The irrational number e is not always understood #2455

josd opened this issue Jul 21, 2024 · 8 comments

Comments

@josd
Copy link
Contributor

josd commented Jul 21, 2024

The following case https://github.com/eyereasoner/eye/blob/1ea6435149beb4d4a483ddb761eae85def65db16/see/temp/complex.pl gives

$ scryer-prolog -g test complex.pl
'https://josd.github.io/cigol#exp'([-1,0],[0.5,0],[6.123233995736766e-17,1.0]).
run,halt causes: error(type_error(evaluable,e),(is)/2)
?-

whereas we expect

$ tpl -g test complex.pl
'https://josd.github.io/cigol#exp'([-1,0],[0.5,0],[6.123233995736766e-17,1.0]).
'https://josd.github.io/cigol#exp'([e,0],[0,pi],[-1.0,1.2246467991473532e-16]).
'https://josd.github.io/cigol#log'([e,0],[-1,0],[0.0,3.141592653589793]).
'https://josd.github.io/cigol#log'([0,1],[0,1],[1.0,0.0]).
'https://josd.github.io/cigol#sin'([1.5707963267949,1.316957896924817],[2.0,-6.6312755068093511e-16]).
'https://josd.github.io/cigol#cos'([0,-1.316957896924817],[2.0,0.0]).
'https://josd.github.io/cigol#tan'([1.338972522294493,0.402359478108525],[1.0,2.0]).
'https://josd.github.io/cigol#asin'([2,0],[1.5707963267949,1.31695789692482]).
'https://josd.github.io/cigol#acos'([2,0],[0.0,-1.31695789692482]).
'https://josd.github.io/cigol#atan'([1,2],[1.33897252229449,0.402359478108525]).

The irrational number pi seems to be understood correctly.
This is also fine

$ scryer-prolog
?- X is e^pi.
   X = 23.140692632779263.
?- X is pi^e.
   X = 22.45915771836104.
?-
@triska
Copy link
Contributor

triska commented Jul 21, 2024

Excellent catch!

I have reduced this to the following test case:

:- use_module(library(debug)).

p([X], Y) :-
        $Y is X.

Yielding:

?- p("e", R).
call:(A is e).
exception:error(type_error(evaluable,e),(is)/2):(A is e).
   error(type_error(evaluable,e),(is)/2), unexpected.

On the other hand, querying the traced goal in isolation works as expected:

?- A is e.
   A = 2.718281828459045. % expected

@hurufu
Copy link
Contributor

hurufu commented Jul 21, 2024

I think this is even shorter:

?- [X] = "e", _ is X.

Surprisingly it works for pi:

?- [X] = [pi], _ is X.

@triska
Copy link
Contributor

triska commented Jul 21, 2024

It looks suspiciously like yet another issue due to the currently only partially finished partial string representation (#24).

@josd
Copy link
Contributor Author

josd commented Jul 21, 2024

Makes sense, also this

?- [X,Y] = [e,foo], Z is X.
   X = e, Y = foo, Z = 2.718281828459045.

works fine whereas this

?- [X,Y] = [e,f], Z is X.
   error(type_error(evaluable,e),(is)/2).

is not working fine.

@josd
Copy link
Contributor Author

josd commented Jul 29, 2024

@triska
Copy link
Contributor

triska commented Sep 28, 2024

The problem got worse with rebis-dev:

?- _ is e.
   error(type_error(evaluable,e),(is)/2), unexpected.
   true. % expected; works in master

@triska
Copy link
Contributor

triska commented Oct 27, 2024

I found a workaround so that you can at least continue for the time being if you want to use it:

?- X is 0 + e.
   X = 2.718281828459045.

@josd
Copy link
Contributor Author

josd commented Oct 27, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants