Stavros Macrakis | 1 Jun 2012 18:50
Picon
Favicon
Gravatar

Re: Implicit: Taylor, Poiseux and Newton's diagram

On Fri, Jun 1, 2012 at 3:29 AM, Oliver Kullmann <O.Kullmann <at> swansea.ac.uk> wrote:
By the way, how would one actually check in Maxima for identity, so that
"1+1" is only identical to "1+1" and nothing else? It seems the evaluation
(rewriting) of 1+1 to 2 is hard to avoid?

In Maxima, it is important to distinguish between "evaluation" (substitution of values, calling of imperative routines) and "simplification" (rewriting).

Almost every part of Maxima dealing with mathematical objects depends on its input being in simplified form.  For example, almost nothing in Maxima recognizes the unsimplified quotient a/b -- internally, it is always handled as a*b^-1.  So for instance with simp=false, diff(x/x,x) => 'diff(x/x,x), though diff(x*x^-1,x) => x^-1*(x^-1*(-1)+log(x)*0)*x+1*x^-1 (which simplifies to 0).

Normally, simplification is on or off globally, so it is not easy to avoid simplification (rewriting) while also dealing with normal (simplifying) operations.  However, it is possible to construct unsimplified expressions and force Maxima to treat them as if they were simplified -- see simpfunmake in my package simplifying.lisp (cf. http://www.ma.utexas.edu/pipermail/maxima/2011/024588.html).  Some operations on these pseudo-simplified expressions will force simplification, and what exactly other operations perform on them is not easy to guess:

(%i19) load("simplifying.lisp")$
(%i20) foo: simpfunmake(verbify("*"),[2,3,a,a]);
(%o20) 2*3*a*a
(%i21) ?print(%);
((MTIMES SIMP) 2 3 $A $A) 
(%o21) 2*3*a*a
(%i22) foo/2;
(%o22) 3*a*a          <<< the 2 is cancelled
(%i23) foo/3;
(%o23) 2*3*a*a/3     <<< the 3 is not...
(%i24) foo/a;
(%o24) 2*3*a           <<< the a is cancelled
(%i25) foo/a^2;
(%o25) 2*3*a/a        <<< one a is cancelled, but not the other...
(%i26) is(foo=foo);
(%o26) true
(%i27) is(foo=6*a^2);
(%o27) false
(%i28) is(equal(foo,6*a^2));
(%o28) true              <<< "is" performs "mathematical" equality, not formal equality

Order matters:

(%i31) bar: simpfunmake(verbify("*"),[a,2,a]);
(%o31) a*2*a
(%i32) bar/2;
(%o32) a*2*a/2
(%i33) bar/a;
(%o33) 2*a
(%i34) bar/a^2;
(%o34) 2*a/a

(%i43) bqz: simpfunmake(verbify("*"),[b,a,2,a,b]);
(%o43) b*a*2*a*b
(%i44) bqz/a;
(%o44) b*a*2*a*b/a

It's not clear to me exactly what problem you're trying to solve, but perhaps that helps?

Of course, another approach is simply to use your own functions/operators.  Maxima is perfectly happy to deal with undefined functions in prefix or infix form:

(%i46) infix("%%");
(%o46) "%%"
(%i47) a %% b;
(%o47) a %% b

for which you can define your own rewrite rules (?? patterns) to apply automatically or only on demand.

          -s

_______________________________________________
Maxima mailing list
Maxima <at> math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima

Gmane