Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

how to restore latex_name

I wonder how to restore the latex_name attribute of a function or variable after saving to a file

my code is:

fx = function('fxf', latex_name=r'f_x')(y);
eq = fx.diff(y)

then I save the equation with

save(eq,'eq')

In a new session I do

fx = function('fxf', latex_name=r'f_x')(y)
eq=load('eq')

but

show(latex(eq))

does not show the latex expression for f_x but sill stays with diff(fxf(y),y) How can I restore the latex output with "f_x"?

how to restore latex_name

I wonder how to restore the latex_name attribute of a function or variable after saving to a file

my (updated) code is:

var('y')
fx = function('fxf', latex_name=r'f_x')(y);
eq = fx.diff(y)
function('fx',latex_name=r'f_x')
eq=fx(y)+fx(y).diff(y)
save([y,fx,eq],'test')

then I save check the equation withlatex expression:

save(eq,'eq')
> print(latex(eq)) 
f_x\left(y\right) + \frac{\partial}{\partial y}f_x\left(y\right)

In a new session I doload the definitions and print the latex forms:

fx = function('fxf', latex_name=r'f_x')(y)
eq=load('eq')
y,fx,eq=load('test')
print(latex(fx))
print(latex(eq))

but with output

show(latex(eq))
f_x
{\rm fx}\left(y\right) + \frac{\partial}{\partial y}{\rm fx}\left(y\right)

does not show curiously the latex form of the function 'f_x' is preserved by it is not used in the symbolic expression for f_x but sill stays with diff(fxf(y),y) How can I restore the latex output with "f_x"?'eq', where only 'fx' appears.

how to restore latex_name

I wonder how to restore the latex_name attribute of a function or variable after saving to a file

my (updated) code is:

var('y')
fx = function('fx',latex_name=r'f_x')
eq=fx(y)+fx(y).diff(y)
save([y,fx,eq],'test')

check the latex expression:

> print(latex(eq)) 
f_x\left(y\right) + \frac{\partial}{\partial y}f_x\left(y\right)

In a new session I load the definitions and print the latex forms:

y,fx,eq=load('test')
print(latex(fx))
print(latex(eq))

with output

f_x
{\rm fx}\left(y\right) + \frac{\partial}{\partial y}{\rm fx}\left(y\right)

curiously the latex form of the function 'f_x' is preserved by it is not used in the symbolic expression 'eq', where only 'fx' appears.

So I thought I do the following: I define a new function and substitute the new function in eq

ffx = function('ffx',latex_name=r'f_x')
print( latex( eq.substitute_function(fx,ffx) ) )

but I still get fx in the output, it seems fx in eq is not the function fx , I cannot even substitute it against another function!

how to restore latex_name

I wonder how to restore the latex_name attribute of a function or variable after saving to a file

my (updated) code is:

var('y')
fx = function('fx',latex_name=r'f_x')
eq=fx(y)+fx(y).diff(y)
save([y,fx,eq],'test')

check the latex expression:

> print(latex(eq)) 
f_x\left(y\right) + \frac{\partial}{\partial y}f_x\left(y\right)

In a new session I load the definitions and print the latex forms:

y,fx,eq=load('test')
print(latex(fx))
print(latex(eq))

with output

f_x
{\rm fx}\left(y\right) + \frac{\partial}{\partial y}{\rm fx}\left(y\right)

curiously the latex form of the function 'f_x' is preserved by but it is not used in the symbolic expression 'eq', where only 'fx' appears.

So I thought I do the following: I define a new function and substitute the new function in eq

ffx = function('ffx',latex_name=r'f_x')
print( latex( eq.substitute_function(fx,ffx) ) )

but I still get fx in the output, it seems fx in eq is not the function fx , I cannot even substitute it against another function!