Maxima can translate Maxima functions into Lisp with the 'translate'
function, like this:
...Perform some symbolic calculation...
qq: integrate(x^4*log(x),x)$
... define a function with that formula...
define(fun(x),funmake('block,['(modedeclare(x,float)),%o2]))
...the modedeclare is necessary because otherwise Maxima will assume that
fun's argument is symbolic, and use symbolic operations on it...
...translate into Lisp...
translate(fun)
...inspect result...
:lisp (symbol-function '$fun) ... Maxima function fun is Lisp function
$fun
(LAMBDA-BLOCK $FUN ($X)
(DECLARE (SPECIAL $X) (TYPE FLONUM $X))
((LAMBDA ()
NIL
NIL
(+ (* -0.040000000000000001 (EXPT$ $X 5))
(* 0.20000000000000001 (EXPT$ $X 5) (LOG $X))))))
...you'll see that Maxima in some cases uses its own version of Lisp
functions, like EXPT$ instead of EXPT, which you'll want to either define
or substitute.
-s
On Fri, Jul 19, 2013 at 5:43 AM, Tamas Papp <tkpapp at gmail.com> wrote:
> Hi,
>
> Is there a quick & easy way to translate results of calculations to
> Common Lisp (or any Lisp) sexps? Eg a+b*c would become (+ a (* b c)),
> etc. I need this because I would like to use analytical results,
> calculated with Maxima, in a CL program, and I don't want to transcribe
> it manually if that can be avoided.
>
> Best,
>
> Tamas
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>