Calling Maxima $diff from java



Mohamed Rayes <rayes.o.mohamed at gmail.com> writes:
> I have compiled maxima with ABCL as described in
> http://comments.gmane.org/gmane.lisp.armedbear.devel/2365. I even
> successfully ran a java program that calls maxima $Factors. The
> program is listed at the end of this message.
>
> I tried calling the $DIFF (as in $DIFF(sin(x),x)) function in the
> following way:
>
> 1- manually translated sin(x) to maxima internal rep: sin(x) ==> ((%sin) $x)
> 2- calling $Diff:
>
> Interpreter I = Interpreter.createInstance ();
> I.eval ("(require 'asdf)");
> I.eval ("(asdf:operate 'asdf:load-op :maxima)");
> Package P = Packages.findPackage ("MAXIMA");
> LispObject exp = I.eval("'(%SIN) $x)");
> LispObject x = I.eval("'$x");
> Symbol S = P.findAccessibleSymbol ("$DIFF");
> Function F = (Function) S.getSymbolFunction ();
> LispObject result = F.execute(exp,p);
>
> I keep getting the error that $DIFF was not found?
>
> Thanks for all the help.

Ah, I see. I haven't used ABCL, but what you've pasted here looks
plausible (in particular, you've got the case of $DIFF correct in the
code). Can you post the actual error you're getting? One of us might be
able to help more.

Once you've got hold of the $DIFF function, I'm also not sure that your
two "eval" lines are going to work. You see, you haven't told the
interpreter "I" to change the current package to MAXIMA. As such, I
think that

   LispObject x = I.eval("'$x");

will work by first reading the string "'$x" to the lisp form

  (QUOTE CL-USER::$X)

and then evaluating, to get the symbol CL-USER::$X. However, you want
the symbol MAXIMA::$X. Presumably the Interpreter object has a method to
change package?

Rupert
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 315 bytes
Desc: not available
URL: <http://www.math.utexas.edu/pipermail/maxima/attachments/20130325/cf20dd17/attachment.pgp>;