Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

substitute_function when function is a diff ?

Hi I simplified my question as I was asked,:

var('xt,m,k,F,omega,E',domain='real')

phi_x(t)=function(r'\phi_x')(t)
dphi_x=diff(phi_x,t,1)
p_x=function('p_x')(t)
#p_x=m*diff(phi_x,t,1)

eqTest=E == 1/2*m*omega^2*phi_x(t)^2 + 1/2*m*dphi_x^2
eqTest_wished=E(t) == 1/2*m*omega^2*phi_x(t)^2 + 1/2*p_x^2/m
print('is it possible to transform equation eqTest into equation eqTest_wished with Sagemath ?')
show('eqTest_wished : \t', eqTest_wished)

show("###############################################################")

show('eqTest : \t \t \t', eqTest)
eqTest_Modified=eqTest.substitute_function(dphi_x,p_x/m)
show('attempt to Modified eqTest : \t \t ', eqTest_Modified)

#eqTest.substitute_function?

how to transform equation eqTest into equation eqTest_wished using SageMath ?

substitute_function when function is a diff ?

Hi I simplified my question as I was asked,:asked:

var('xt,m,k,F,omega,E',domain='real')
var('m, omega, E', domain='real')
 phi_x(t)=function(r'\phi_x')(t)
dphi_x=diff(phi_x,t,1)
p_x=function('p_x')(t)
#p_x=m*diff(phi_x,t,1)
phi_x(t) = function('phi_x', latex_name=r'\phi_x')(t)
dphi_x = diff(phi_x, t, 1)
p_x = function('p_x')(t)
# p_x = m*diff(phi_x, t, 1)
 eqTest=E eqTest = E == 1/2*m*omega^2*phi_x(t)^2 + 1/2*m*dphi_x^2
eqTest_wished=E(t) eqTest_wished = E(t) == 1/2*m*omega^2*phi_x(t)^2 + 1/2*p_x^2/m
print('is it possible print('We wish to transform equation eqTest into equation eqTest_wished obtain `eqTest_wished` with Sagemath ?')
SageMath:')
show('eqTest_wished : \t', eqTest_wished)

show("###############################################################")

show("by using substitutions starting from `eqTest`:")
show('eqTest : \t \t \t', eqTest)
eqTest_Modified=eqTest.substitute_function(dphi_x,p_x/m)
show('attempt to Modified eqTest : 
# Failed attempt
eqTest_Modified = eqTest.substitute_function(dphi_x, p_x/m)
show('Failed attempt: \t \t ', eqTest_Modified)

#eqTest.substitute_function?

how How to transform equation eqTest eqTest into equation eqTest_wished eqTest_wished using SageMath ?