Opened 2 years ago
Last modified 12 months ago
#21754 needs_info defect
Held symbolic powers cannot be approximated numerically
Reported by: | rws | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | sage-7.5 |
Component: | symbolics | Keywords: | |
Cc: | Merged in: | ||
Authors: | Ralf Stephan | Reviewers: | Vincent Delecroix |
Report Upstream: | N/A | Work issues: | |
Branch: | u/rws/held_symbolic_powers_cannot_be_approximated_numerically (Commits) | Commit: | e1279df568cd86ba1e42a00a71db6f689b19825b |
Dependencies: | Stopgaps: |
Description
Maybe a bit obscure but still a bug:
sage: SR(2).power(SR(QQbar(3).sqrt() + QQbar(2).sqrt()), hold=True) 2^3.146264369941973? sage: _.n() ... TypeError: no canonical coercion from Algebraic Field to Rational Field
Reason is that in Expression.n()
the special sum treatment via class DefiniteSumExpander(ExpressionTreeWalker)
leaves arithmetic operations to the superclass where (if all numeric) they are reduced to their non-symbolic calls, i.e. here, 2^QQbar(...)
which gives the error (correctly, see https://groups.google.com/forum/?hl=en#!topic/sage-support/_7eGYj92Igw).
As we want to hold the power until later numerical conversion we want to override arithmetic
in DefiniteSumExpander
.
Change History (6)
comment:1 Changed 2 years ago by
- Branch set to u/rws/held_symbolic_powers_cannot_be_approximated_numerically
comment:2 Changed 2 years ago by
- Commit set to e1279df568cd86ba1e42a00a71db6f689b19825b
- Status changed from new to needs_review
comment:3 follow-up: ↓ 4 Changed 2 years ago by
- Reviewers set to Vincent Delecroix
- Status changed from needs_review to needs_work
You added a method without neither documentation nor tests.
The following still fails
sage: SR(2) ^ SR(QQbar(3).sqrt() + QQbar(2).sqrt())
Would it be possible to hold the power automatically when there is no simplification?
comment:4 in reply to: ↑ 3 ; follow-up: ↓ 5 Changed 2 years ago by
- Status changed from needs_work to needs_review
Replying to vdelecroix:
You added a method without neither documentation nor tests.
In a locally used class, come on, show me one example where this is done in Sage. It won't show in coverage, either:
ralf@ark:~/sage> ./sage -coverage src/sage/symbolic/expression.pyx ------------------------------------------------------------------------ SCORE src/sage/symbolic/expression.pyx: 100.0% (220 of 220) ------------------------------------------------------------------------
The test is in the containing function, of course.
The following still fails
sage: SR(2) ^ SR(QQbar(3).sqrt() + QQbar(2).sqrt())Would it be possible to hold the power automatically when there is no simplification?
I can catch the type error, but then I will catch all type errors. Is this desireable?
comment:5 in reply to: ↑ 4 Changed 2 years ago by
comment:6 Changed 12 months ago by
- Status changed from needs_review to needs_info
New commits:
21754: Held symbolic powers cannot be approximated numerically