On Tue, 27 Nov 2012 12:16:20 +0100 Burcin Erocal <[email protected]> wrote:
> On Tue, 27 Nov 2012 11:23:01 +0100 > Serge Torres <[email protected]> wrote: > > > I'm pretty sure this question has been answered over and over but > > despite intensive googling I could not find these answers. > > > > I have expressions (say, f = exp(x)) that want to export to another > > computing system. > > > > str(f) is 'e^x' but the target system does not understand it. > > > > Is there a way to have a string version of f with the exp() notation > > preserved? > > This is #11428 on trac. > > http://trac.sagemath.org/sage_trac/ticket/11428 > > The patch on the ticket does not work. It needs to go through the > registry of functions stored in Pynac and update the name or the > printing functions there. Unfortunately I don't have time to implement > that right now. > > > As a workaround in your case, you can modify the definition of > Function_exp in sage/functions/log.py to set a latex_name in the > initializer, or if that doesn't work, define a _print_latex_ method. Here is a simpler solution: Create a symbolic function fn that prints as '\exp', replace e^x in your expression with fn, translate the new expression to latex: # the top level function method injects the name of the function into # the name space. I don't want to overwrite the exp method in the top # level. Hence the import sage: from sage.symbolic.function_factory import function sage: fn = function('exp', latex_name='\exp') sage: fn exp sage: type(exp) <class 'sage.functions.log.Function_exp'> sage: latex(fn(x)) \exp\left(x\right) sage: t = exp(x^2) + (x+1)*exp(a^2+b) sage: latex(t) {\left(x + 1\right)} e^{\left(a^{2} + b\right)} + e^{\left(x^{2}\right)} sage: latex(t.substitute_function(exp, myfn)) {\left(x + 1\right)} \exp\left(a^{2} + b\right) + \exp\left(x^{2}\right) Cheers, Burcin -- You received this message because you are subscribed to the Google Groups "sage-support" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sage-support?hl=en.
