# why does substitute() not work with canonicalize_radical()

With a symbolic expression, i take two attempts to substitute a term within the expression. In the first, which was simplified with canonicalize_radical(), substitution is not working, but in the second, without canonicalize_radical(), the substitution is working. Why is it?

This is the smallest example i could think at this moment, but it reproduces the behavior

t,u,v = var('t,u,v')
phi(u,v) = cos(u)*v
g_x(t) = function(r'\gamma_x')(t)
g_y(t) = function(r'\gamma_y')(t)
vs = diff(phi(g_x(t), g_y(t)), t)
vs


"-\gamma_y(t)sin(\gamma_x(t))diff(\gamma_x(t), t) + cos(\gamma_x(t))*diff(\gamma_y(t), t)"

conds = [cos(g_x(t))==1, sin(g_x(t)) ==0]


"-\gamma_y(t)sin(\gamma_x(t))diff(\gamma_x(t), t) + cos(\gamma_x(t))*diff(\gamma_y(t), t)"

vs.substitute(conds)


︡"diff(\gamma_y(t), t)"

edit retag close merge delete

The way you (ab)use "symbolic functions" (callable symbolic expressions) definition bit you :

sage: g_x(t) = function(r'\gamma_x')(t)
sage: g_x
t |--> \gamma_x(t)
sage: gamma_x
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
/usr/local/sage-9/src/sage/all_cmdline.py in <module>
----> 1 gamma_x

NameError: name 'gamma_x' is not defined


why not :

sage: g_x=function("g_x", latex_name=r"\gamma_x")
sage: g_x
g_x
sage: latex(g_x)
\gamma_x

( 2022-07-04 09:43:10 +0100 )edit

i didnt know it made a difference. thanks!

( 2022-07-04 10:07:26 +0100 )edit