#19993 closed enhancement (fixed)
Arb: parse symbolic expressions
Reported by: | cheuberg | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | sage-7.1 |
Component: | numerical | Keywords: | arb |
Cc: | behackl, dakrenn, mmezzarobba, fredrik.johansson | Merged in: | |
Authors: | Clemens Heuberger | Reviewers: | Daniel Krenn |
Report Upstream: | N/A | Work issues: | |
Branch: | 2c2955f (Commits) | Commit: | |
Dependencies: | Stopgaps: |
Description
Current behaviour:
sage: RBF(zeta(3)) [1.202056903159590 +/- 5.38e-16] sage: RBF(2*zeta(3)) Traceback (most recent call last): ... TypeError: unable to convert 2*zeta(3) to a RealBall
That is unfortunate (imagine that this is part of a large symbolic expression, involving various constants, logarithms etc.)
I assume that the first call succeeds because RIF
can handle it.
Change History (13)
comment:1 Changed 5 years ago by
- Branch set to u/cheuberg/arb/parse-symbolic
comment:2 Changed 5 years ago by
- Commit set to f39f484721b7faa7a1fec1adc44d8ae424785c79
- Status changed from new to needs_review
comment:3 Changed 5 years ago by
- Cc fredrik.johansson added
comment:4 Changed 5 years ago by
- Cc mmezzarobba added; mmezzaroba removed
comment:5 Changed 5 years ago by
- Status changed from needs_review to needs_work
I am now dealing with the failing doctests on the patchbot.
comment:6 Changed 5 years ago by
- Commit changed from f39f484721b7faa7a1fec1adc44d8ae424785c79 to 2c2955f15ed22920dc9599085a9dd63e68a512f7
comment:7 Changed 5 years ago by
- Status changed from needs_work to needs_review
The failing doctests were probably introduced by #19082; thus I had to merge 7.1.beta1 to fix them (only errors were affected, mostly they improved; in one occurrence, we now have a slightly worse error). All this is due to not involving RIFs less frequently.
comment:8 follow-up: ↓ 9 Changed 5 years ago by
It might be worth handling rational arguments in some cases, if it's not too complicated?
x^{(2/3)} -> arb_pow_fmpq
exp(I*pi/3) -> arb_sin_cos_pi_fmpq
gamma(1/3) -> arb_gamma_fmpq
comment:9 in reply to: ↑ 8 Changed 5 years ago by
Replying to fredrik.johansson:
It might be worth handling rational arguments in some cases, if it's not too complicated?
For each operand in a symbolic expression, we could check whether it is an element of QQ
and, in that case, just take the .pyobject
of the operand instead of converting it into the Real Ball Field. Then it would be the responsibility of the respective functions to deal with those elements appropriately (either by the coercion model or by hand).
x^{(2/3)} -> arb_pow_fmpq
in that case, we should also modify __pow__
which currently does not consider rational exponents.
exp(I*pi/3) -> arb_sin_cos_pi_fmpq
I am not sure that we want to do that much parsing of a symbolic expression.
gamma(1/3) -> arb_gamma_fmpq
tricky: we would have to hardwire this function because we'd have to call RealBallField.gamma
.
I think I'd prefer to postpone such optimizations to a follow-up ticket.
comment:10 follow-up: ↓ 11 Changed 5 years ago by
- Reviewers set to Daniel Krenn
- Status changed from needs_review to positive_review
LGTM, and as suggested, everything else should be on a follow up ticket.
BTW, is
sage: zeta(RIF(3)).parent() Complex Field with 53 bits of precision
known? (It works with balls, so no need to worry about this ticket...)
comment:11 in reply to: ↑ 10 Changed 5 years ago by
comment:12 Changed 5 years ago by
- Branch changed from u/cheuberg/arb/parse-symbolic to 2c2955f15ed22920dc9599085a9dd63e68a512f7
- Resolution set to fixed
- Status changed from positive_review to closed
comment:13 Changed 14 months ago by
- Commit 2c2955f15ed22920dc9599085a9dd63e68a512f7 deleted
A bug proably introduced by this ticket:
sage: RBF(exp(1), 1) [2.718281828459045 +/- 5.41e-16]
See #28469.
New commits:
Trac #19993: Arb: parse symbolic expressions