On 11/26/12 13:19, Dan Drake wrote:
On Mon, 26 Nov 2012 at 10:10AM -0800, ijt wrote:
I was wondering if there is any way to make sage produce an output
that I can directly use in java code? I am using sage to compute
gradients and hessians of multidim. functions which become quite large
and replacing everything by hand is quite annoying.

For example, sage returns something like:

exp(x^2*log(z)-sqrt(y^5))

which in java code would look like

Math.exp(Math.pow(x,2)*Math.log(z)-Math.sqrt(Math.pow(y,5)))

I don't have a good answer for this (other than string manipulation and
regex matching -- if you want to be a little fancier, try the pyparsing
module), but there's a more general question here: how to rewrite Sage
expressions into other forms?

In some sense, we already do this in many places (the pty interfaces,
the LaTeX output), but I wonder if there's a nice way to overload some
of that stuff and define your own outputs, so that "exp()" becomes
"Math.exp()", just like

     latex(sin(x))

is

      \sin\left(x\right)


Thoughts?

If you want sage to be competitive with Mathematica, you should definitely make an equivalent of "CForm".

--
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.


Reply via email to