# 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.

edit retag close merge delete

Sort by ยป oldest newest most voted

Possible workaround :

sage: var("x, omega, t");
sage: u=function("u")
sage: def eq():return u(1)==cos(omega*t)
sage: eq()
u(1) == cos(omega*t)
sage: u(x)=e^(2*t*x)
sage: eq()
e^(2*t) == cos(omega*t)


But I fail to see the point...

HTH,

more

Yes thank you, this is a convenient solution.

( 2022-05-19 17:10:22 +0100 )edit

## Stats

Seen: 94 times

Last updated: May 19 '22