Skip to content

Held symbolic powers cannot be approximated numerically #21754

Open
@rwst

Description

@rwst

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.

Component: symbolics

Author: Ralf Stephan

Branch/Commit: u/rws/held_symbolic_powers_cannot_be_approximated_numerically @ e1279df

Reviewer: Vincent Delecroix

Issue created by migration from https://trac.sagemath.org/ticket/21754

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions