Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Obviously it is possible to assign any latex text to derivatives by using the ' derivative_func' -option of the 'function'- procedure. I have attached an example that I have executed in the SAGE V63 environment.

Obviously it is possible to assign any latex text to derivatives by using the ' derivative_func' -option of the 'function'- procedure. Below I have attached addad an example that I have executed in the SAGE V63 environment.

var('z')

def dfx(self,args,*kwds):return dfxdz(z)

def dfy(self,args,*kwds):return dfydz(z)

fx=function('fx',derivative_func=dfx,latex_name='x')

fy=function('fy',derivative_func=dfy,latex_name='y')

dfxdz=function('dfxdz',latex_name='\frac{\operatorname{d}{x}}{\operatorname{d}{z}}')

dfydz=function('dfydz',latex_name='\frac{\operatorname{d}{y}}{\operatorname{d}{z}}')

dgdx=function('dgdx',latex_name='\frac{\partial{g}}{\partial{x}}')

dgdy=function('dgdy',latex_name='\frac{\partial{g}}{\partial{y}}')

pdev=[dgdx(fx(z)),dgdy(fy(z))]

xf=fx(z)

yf=fy(z)

def pderivg(self, args, *kwds): print "args:",args; print "kwds:",kwds,pdev[kwds['diff_param']]; return pdev[int(kwds['diff_param'])]

gf = function('gf', latex_name='g',nargs=2, derivative_func=pderivg)

g=gf(xf,yf)

deriv=g.derivative(z)

show(deriv)

Obviously it is possible to assign any latex text to derivatives by using using the ' derivative_func' -option derivative_func option of the 'function'- procedure. function function.

Below I have addad added an example that I have executed in the SAGE V63 environment.Sage 6.3.

var('z')

var('z')
 def dfx(self, *args, **kwds):
    return dfxdz(z)
 

def dfx(self,args,*kwds):return dfxdz(z)

dfy(self,*args,**kwds): return dfydz(z) fx = function('fx', derivative_func=dfx, latex_name='x') fy = function('fy', derivative_func=dfy, latex_name='y')

def dfy(self,args,*kwds):return dfydz(z)

dfxdz = function('dfxdz', latex_name=r'\frac{\operatorname{d}{x}}{\operatorname{d}{z}}') dfydz = function('dfydz', latex_name=r'\frac{\operatorname{d}{y}}{\operatorname{d}{z}}') dgdx = function('dgdx', latex_name=r'\frac{\partial{g}}{\partial{x}}') dgdy = function('dgdy', latex_name=r'\frac{\partial{g}}{\partial{y}}')

fx=function('fx',derivative_func=dfx,latex_name='x')

pdev = [dgdx(fx(z)), dgdy(fy(z))] xf = fx(z) yf = fy(z)

fy=function('fy',derivative_func=dfy,latex_name='y')

dfxdz=function('dfxdz',latex_name='\frac{\operatorname{d}{x}}{\operatorname{d}{z}}')

dfydz=function('dfydz',latex_name='\frac{\operatorname{d}{y}}{\operatorname{d}{z}}')

dgdx=function('dgdx',latex_name='\frac{\partial{g}}{\partial{x}}')

dgdy=function('dgdy',latex_name='\frac{\partial{g}}{\partial{y}}')

pdev=[dgdx(fx(z)),dgdy(fy(z))]

xf=fx(z)

yf=fy(z)

def pderivg(self, args, *kwds): print "args:",args; print "kwds:",kwds,pdev[kwds['diff_param']]; *args, **kwds): print("args:", args) print("kwds:", kwds, pdev[kwds['diff_param']]) return pdev[int(kwds['diff_param'])]

pdev[int(kwds['diff_param'])]

gf = function('gf', latex_name='g',nargs=2, derivative_func=pderivg)

derivative_func=pderivg) g = gf(xf, yf) deriv = g.derivative(z) show(deriv)

g=gf(xf,yf)

deriv=g.derivative(z)

show(deriv)

Obviously it is possible to assign any latex text to derivatives by using the derivative_func option of the function function.

Below I have added an example that I have executed in Sage 6.3.

(Note: edited to make print python3-compatible. Now works in Sage 9.8.)

var('z')

def dfx(self, *args, **kwds):
    return dfxdz(z)

def dfy(self,*args,**kwds):
dfy(self, *args,**kwds):
    return dfydz(z)

fx = function('fx', derivative_func=dfx, latex_name='x')
fy = function('fy', derivative_func=dfy, latex_name='y')

dfxdz = function('dfxdz', latex_name=r'\frac{\operatorname{d}{x}}{\operatorname{d}{z}}')
dfydz = function('dfydz', latex_name=r'\frac{\operatorname{d}{y}}{\operatorname{d}{z}}')

dgdx = function('dgdx', latex_name=r'\frac{\partial{g}}{\partial{x}}')
dgdy = function('dgdy', latex_name=r'\frac{\partial{g}}{\partial{y}}')

pdev = [dgdx(fx(z)), dgdy(fy(z))]

xf = fx(z)
yf = fy(z)

def pderivg(self, *args, **kwds):
    print("args:", args)
    print("kwds:", kwds, pdev[kwds['diff_param']])
    return pdev[int(kwds['diff_param'])]

gf = function('gf', latex_name='g',nargs=2, latex_name='g', nargs=2, derivative_func=pderivg)
g = gf(xf, yf)
deriv = g.derivative(z)
show(deriv)