# Revision history [back]

One way to deal with this would be to define a python function that creates a new symbolic function out of an already defined variable, while keeping the latex representation of the original variable for illustration purposes:

def f(var1, var2): ''' Creates a symbolic function out of existing variable, where the name of the function is f-underscore followed by the name of the existing variable, while the latexname of the original variable, if defined, stays the same. Returns the function evaluated at another defined variable given as var2. Example: sage: var('B E H T_s') sage: eq_B = B == H/E sage: eq1 = diff(eq_B.subs(B = f(B,T_s), H = f(B,T_s), E = f(E,T_s)), T_s) sage: latex(eq1) D[0]\left(B\right)\left(T_{s}\right) = \frac{D[0]\left(B\right)\left(T_{s}\right)}{E\left(T_{s}\right)} - \frac{B\left(T_{s}\right) D[0]\left(E\right)\left(T_{s}\right)}{E\left(T_{s}\right)^{2}} ''' name = 'f_'+str(var1) z = function(name,latex_name = latex(var1)) return z(var2)

One I just found a way to deal with this this, which would be to define a python function that creates a new symbolic function out of an already defined variable, while keeping the latex representation of the original variable for illustration purposes:

def f(var1, var2):
'''
Creates a symbolic function out of existing variable,
where the name of the function is f-underscore followed
by the name of the existing variable, while the latexname
of the original variable, if defined, stays the same.
Returns the function evaluated at another defined variable
given as var2.
Example:
sage: var('B E H T_s')
sage: eq_B = B == H/E
sage: eq1 = diff(eq_B.subs(B = f(B,T_s), H = f(B,T_s), E = f(E,T_s)), T_s)
sage: latex(eq1)
D[0]\left(B\right)\left(T_{s}\right) =
\frac{D[0]\left(B\right)\left(T_{s}\right)}{E\left(T_{s}\right)} -
\frac{B\left(T_{s}\right)
D[0]\left(E\right)\left(T_{s}\right)}{E\left(T_{s}\right)^{2}}
'''
name = 'f_'+str(var1)
z = function(name,latex_name = latex(var1))
return z(var2) z(var2)


I just found a way to deal with this, which would be to define a python function that creates a new symbolic function out of an already defined variable, while keeping the latex representation of the original variable for illustration purposes:

def f(var1, var2):
'''
Creates a symbolic function out of existing variable,
where the name of the function is f-underscore followed
by the name of the existing variable, while the latexname
of the original variable, if defined, stays the same.
Returns the function evaluated at another defined variable
given as var2.
Example:
sage: var('B E H T_s')
sage: eq_B = B == H/E
sage: eq1 = diff(eq_B.subs(B = f(B,T_s), H = f(B,T_s), f(H,T_s), E = f(E,T_s)), T_s)
sage: latex(eq1)
D[0]\left(B\right)\left(T_{s}\right) =
\frac{D[0]\left(B\right)\left(T_{s}\right)}{E\left(T_{s}\right)} -
\frac{B\left(T_{s}\right)
D[0]\left(E\right)\left(T_{s}\right)}{E\left(T_{s}\right)^{2}}
= -\frac{H\left(T_{s}\right)
D[0]\left(E\right)\left(T_{s}\right)}{E\left(T_{s}\right)^{2}} +
\frac{D[0]\left(H\right)\left(T_{s}\right)}{E\left(T_{s}\right)}
'''
name = 'f_'+str(var1)
z = function(name,latex_name = latex(var1))
return z(var2)