Subject: Noun forms of elementry arithmetic functions
From: Richard Fateman
Date: Tue, 25 Oct 2005 08:06:49 -0700
There are a variety of other approaches possible.
One is to do this
simp:off;
and then x+1+x remains unchanged.
Another is to not use Maxima, but just write in Lisp.
Another is to forget the nary and prefix stuff and use
functional notation, e.g.
myPlus(x,1,x);
You can then consider modifying the display program
to show x+1+x.
I think you should look first at simp:off
though.
Good luck
RJF
Chris Sangwin wrote:
> I would like to produce detailed worked solutions for students
> automatically in Maxima as part of computer aided assessment
> questions. To do this I would like much finer control over the
> simplifications which Maxima performs to very elementary
> expressions. For example, I would like to manipulate expressions
> such as
>
> x + 1 + x,
>
> without these automatically being simplified to 2*x+1.
>
> To do this I have defined noun forms of the elementry
> arithmetic operators, eg
>
> nary("n+",100);
> prefix("n-",100);
> nary("n*",120);
> infix("n/",122,123);
> infix("n^",140,139);
>
> It is then possible to have expressions such as
>
> x n+ 1 n+ x
>
> or
>
> x n+ n- x
>
> I have started to write functions which manipulate them, such as
> one to convert all operators in an expression to noun form, eg
>
> noun_arith(ex) := block(
> ex:subst("N+","+",ex),
> ex:subst("N*","*",ex),
> ex:subst("N-","-",ex),
> ex:subst("N/","//",ex),
> ex:subst("N^","^",ex),
> ev(ex));
>
> I expect this will develop into a library of related functions and
> so before I start on this in ernest I'd like to discuss this with
> the list. I think such noun forms would be more generally useful
> for many other applications.
>
> (1) Do such noun forms already exist?
>
> (2) Is using the function nary, etc to define these noun forms the
> correct way to proceed in Maxima? If not, what else should I do?
>
> (3) Where can I find information on the binding levels of +, -
> etc? (Those used above were stolen from the mactex.lisp file.)
>
> (4) using factor(2^6-1) returns
>
> ((MTIMES SIMP FACTORED) ((MEXPT SIMP) 3 2) 7)
>
> How does this relate to the proposed noun forms?
>
> (5) I've modified the tex() function to display the noun forms
> exactly as their verb counterparts through lisp code such as
>
> (defprop $n+ tex-mplus tex)
> (defprop $n+ ("+") texsym)
> (defprop $n+ 100. tex-lbp)
> (defprop $n+ 100. tex-rbp)
>
> This works surprisingly well, but I'm (not surprisingly) having
> great difficulty with the unary minus. How can I tell tex() to
> display these noun forms in an identical way to their namesakes?
>
> I've attached two files to give an idea of what progress I have
> made.
>
> Any advice would be very welcome.
>
> Chris