gelpia
gelpia copied to clipboard
Named constants (pi)
Common mathematical constants should be supported in .dop files. The most important constant is pi. Internally, the best possible interval approximation should be used.
I will expose (some) of the internal GAOL constants: two_pi half_pi pi_dn pi_up half_pi_dn half_pi_up ln2_dn ln2_up two_power_53 GAOL_NAN GAOL_INFINITY NaN (quiet)
I believe these are good approximations. Gaol reference (attached for convenience) gaol.pdf page 49
I should also include e
For the constant e it is better to use a different name. For example, e_const.
Somehow I dropped pi from Gaol's constants.
Use intervals for two_pi, half_pi, pi (page 19 of gaol.pdf)
This is (partially) a front-end parser issue, so I'm assigning Ian.
I didn't notice that page 49 is about double versions. It looks like Gaol doesn't have e, so I'll need to get a good interval for it. I'll add it as a constant interval e_const = [down(e), up(e)].
For Ian's reference: Gaol's string constructor uses the tightest possible interval for pi. For now you can pass it straight through as a constant.
The width of the interval for the string "pi" is 1 ULP (in hex, [400921fb54442d18, 400921fb54442d19]), and the full decimal expansion of the lower bound is less than pi and the upper bound is greater than pi.
See https://github.com/soarlab/gelpia/issues/16 for a hint at the general strategy to implement this.
half_pi, two_pi, pi and e_const have been added. The constants are confirmed to be 1 ULP wide interval approximations.
I get the following error now:
bin/dop_gelpia benchmarks/classical_tests/1d/forrester.dop
Traceback (most recent call last):
File "bin/dop_gelpia", line 10, in <module>
import argument_parser as ap
File "/home/alexey/Work/Projects/gelpia/bin/argument_parser.py", line 11, in <module>
from lexed_to_parsed import parse_function
File "/home/alexey/Work/Projects/gelpia/bin/lexed_to_parsed.py", line 162
t[0] = ["ConstantInterval", *SYMBOLIC_CONSTS[t[1]]]
My Python version is 3.4.4
Why did you choose these names: half_pi
, two_pi
, pi
, and e_const
?
They are not uniform since e
has const
added to the end of it. I suspect you did that to ease parsing or something like that, yes?
Anyhow, I think they should either all have const
or not.
The names for the pi related constants come from GAOL itself. There's no difficulty in choosing the name, if Alexey's happy with the names or he has suggestions we'll change them.
Personally I'd prefer constants to be all upper case.
Alexey's issue is fixed in https://github.com/soarlab/gelpia/commit/967d2b948323b6a64df03c2ff6ef10cf7f0bc012. I didn't know until now python 3.5 had this in-place destructuring (I can't find where in python 3.5 this was allowed). I've turned the code into simple list operations.
Sticking w Gaol names seems a good idea (could not type gaol quickly on phone w/o it turning to goal . Then tried Ga ol , and it turned to gold. ...)
On Jul 19, 2016 9:14 AM, "Mark S. Baranowski (Marek Stanisław Baranowski)" < [email protected]> wrote:
The names for the pi related constants come from GAOL itself. There's no difficulty in choosing the name, if Alexey's happy with the names or he has suggestions we'll change them.
Personally I'd prefer constants to all upper case.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/soarlab/gelpia/issues/13#issuecomment-233665029, or mute the thread https://github.com/notifications/unsubscribe-auth/AEyiCne8kESjKf4aZKCXbWUaapy0UI1Sks5qXOm1gaJpZM4JJy4y .
I prefer existing names: pi, half_pi, etc. I don't want to have different naming conventions for regular functions (sin, cos, etc.) and constants (which are 0-arity functions). On the other hand, I agree that the name e_const may be not good. The only problem with e is that the names 'e' and 'E' are not acceptable: there is a big chance that there is a variable 'e' or 'E'.
How about exp
?
http://www.cplusplus.com/reference/cmath/exp/
exp
is already used. One alternative is euler
(but there is another mathematical constant with the same name). Maybe, exp1
(or exp_1
)?
I think I like exp1
the best.
I like exp1 as well. I'll defer the decision to Alexey.
The name exp1
is good. Let's use it.