Skip to content

(x^2).subs({x: sqrt(x)}) returns sqrt(x) instead of x #30378

Closed
@egourgoulhon

Description

@egourgoulhon

As discussed in https://groups.google.com/d/msg/sage-devel/kYZ4N73oiCM/-iDyQLWyBAAJ, we have currently

sage: (x^2).subs({x: sqrt(x)})                                                  
sqrt(x)

A consequence of this bug is

sage: f(x) = x^2                                                                
sage: f(sqrt(x))                                                                
sqrt(x)

Note that the following outputs are correct:

sage: (x^2).subs({x: sqrt(pi)})                                                 
pi
sage: (x^2).subs({x: x^(1/3)})                                                  
x^(2/3)
sage: y = var('y')                                                              
sage: (x^2).subs({x: sqrt(y)})                                                  
y

Moreover, distinct powers of x seem OK:

sage: (x^3).subs({x: sqrt(x)})                                                  
x^(3/2)
sage: (x^(-2)).subs({x: sqrt(x)})                                               
1/x

But a match is problematic:

sage: (x^3).subs({x:x^(1/3)})
x^(1/3)

CC: @nbruin @rwst @kcrisman @EmmanuelCharpentier

Component: symbolics

Keywords: sqrt, substitution, pynac

Author: Dave Morris

Branch: 8d4db46

Reviewer: Matthias Koeppe

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions