Ask Your Question

Revision history [back]

How to recompute symbolic expression

I have a symbolic expression with symbolic evaluation.

After I whand to eval the function to it's expression but it doent work :

var("x, omega, t")
u = function('u')(x)

eq = u(x=1) == cos(omega*t)
eq.show()

u(x) = e^(2*t*x)
eq.show

𝑢(1)=cos(𝜔𝑡)

𝑢(1)=cos(𝜔𝑡)

But now if I create again eq equation, this time it works.

eq2 = u(x=1) == cos(omega*t)
eq2.show()

𝑒(2𝑡)=cos(𝜔𝑡)

Is-it a function recompute to replace easily function by it value ?

The working solution I found isn't practical :

var("x, omega, t")
uf = function('u')(x)

eq = uf(x=1) == cos(omega*t)

eq.show()

u2(x) = e^(2*t*x)

eq.substitute_function(u, u2).show()

I look on subs() and substitute_function() but their behaviour isn't convenient for this case.