Newbie questions



jblazi wrote:
> 
> I am trying to find out whether I can use Maxima for teaching. So I installed
> Maxima (and GCL, by the way).
> 
> I have written a lisp function $f in a file that is called "mytest.lisp" and
> is in the current directory. It is extremely simple:
> 
> (defun $f (x) (* x x))
> 
> Can I load this function into maxima and call it? 

It must be in the same package as maxima, so you need an in-package
line in the file.

It should return (when
> called from Maxima):
> 
> (1) 4 when called like (f 2)

>From a command line it would be called by  f(2);


> (2) 3+2sqrt(2) when called like (f (+ 1 (sqrt 2)))

No, you are call the LISP + function, not the maxima "simplify"
function.
The LIsp  function only knows about the usual numeric lisp data.

To do that you could do, for example  (defun $f(x)(simplifya (list
'(mtimes) x x) t))

which would also return 4.


> (3) a^2+2a+1 when called like (f (+ a 1))
> 
Why don't you just use the maxima functionality?

For example you could do   f(x):=expand(x^2);
translate(f);  ....  change it into lisp
save ("filename", f);

or some similar sequence.  I haven't tried this, but you
should get the idea.
RJF


> (In the third case, maybe some other function like expand in Maple could be
> nexessary, but this would be o.k. What I mean is, my function should be able
> to handle whatever unput is sensible in Maxima.)
> 
> TIA,
> 
> Janos Blazi
> _______________________________________________
> Maxima mailing list
> Maxima@www.math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima