a simplification problem



On Friday 27 June 2008, andre maute wrote:
> On Thursday 26 June 2008, Richard Fateman wrote:
> > Js:{};
> > s(x):= if (not(atom (x)) and inpart(x,0)=J )then Js:union(Js,{x});
> > apply1(t2,s)$
> > Js;
> >
> > I suspect it is faster, but it is certainly shorter.
>
> Much faster 0.8s!

I have two questions regarding the usage of apply1() above. The manual states

-----------------------------------------------------------------------
Function: apply1 (expr, rule_1, ..., rule_n)  
Repeatedly applies rule_1 to expr until it fails, then repeatedly applies the 
same rule to all subexpressions of expr, left to right, until rule_1 has 
failed on all subexpressions. Call the result of transforming expr in this 
manner expr_2. Then rule_2 is applied in the same fashion starting at the top 
of expr_2. When rule_n fails on the final subexpression, the result is 
returned. 
maxapplydepth is the depth of the deepest subexpressions processed by apply1 
and apply2.
------------------------------------------------------------------------

So rule_1, ... rule_n need not be defined with defrule?
Is this an abuse of maxapplydepth because the expression x is not transformed? 

Regards
Andre

P.S. And why is atom(expr) inside
     Chapter 37 (Lists) and not in Chapter 6 (Expressions)?

>
> Thanks
> Andre
>
> On Thursday 26 June 2008, andre maute wrote:
> > On Thursday 26 June 2008, andre maute wrote:
> > > I have the following terms
> > >
> > > ------------------------------------------------------------------
> > > display2d : false;
> > >
> > > t1:(J(r,a+1,b,s+1,t)*(-s+a+1)-J(r,a,b+1,s+1,t)*(a-s))*(t+r+1)
> > >  +(s+r+1)*(J(r,a,b+1,s,t+1)*(-t+b+1)-J(r,a+1,b,s,t+1)*(b-t));
> > >
> > > t2:(s+r+2)*((-t+b+2)*((J(r,a+1,b+1,s+1,t+1)*(-s+a+1)
> > >                   -J(r,a,b+2,s+1,t+1)*(a-s))
> > >                   *(t+r+2)
> > >                   +(s+r+1)*(J(r,a,b+2,s,t+2)*(-t+b+1)
> > >                            -J(r,a+1,b+1,s,t+2)*(b-t)))
> > >         -(b-t)*((J(r,a+2,b,s+1,t+1)*(-s+a+2)
> > >                -J(r,a+1,b+1,s+1,t+1)*(-s+a+1))
> > >                *(t+r+2)
> > >                +(s+r+1)*(J(r,a+1,b+1,s,t+2)*(b-t)
> > >                         -J(r,a+2,b,s,t+2)*(-t+b-1))))
> > >  +(t+r+2)*((-s+a+2)*((J(r,a+2,b,s+2,t)*(-s+a+1)
> > >                     -J(r,a+1,b+1,s+2,t)*(a-s))
> > >                     *(t+r+1)
> > >                     +(s+r+2)*(J(r,a+1,b+1,s+1,t+1)*(-t+b+1)
> > >                              -J(r,a+2,b,s+1,t+1)*(b-t)))
> > >           -(a-s)*((J(r,a+1,b+1,s+2,t)*(a-s)-J(r,a,b+2,s+2,t)*(-s+a-1))
> > >                  *(t+r+1)
> > >                  +(s+r+2)*(J(r,a,b+2,s+1,t+1)*(-t+b+2)
> > >                           -J(r,a+1,b+1,s+1,t+1)*(-t+b+1))));
> > > ----------------------------------------------------------------------
> > >
> > > t1 and t2 were generated with a recursion rule.
> > > t1 and t2 are linear combinations of the J-Terms and r,a,b,s,t are
> > > parameters.
> > >
> > > Is it possible to combine the J-Terms and apply a function,
> > > e.g. factor(), to their coefficients?
> >
> > O.k. I have all J-Terms with
> > -----------------------------------------------------------------------
> > e2 : expand(t2);
> > e2parts : makelist(part(e2,i),i,1,length(e2));
> >
> > matchdeclare(rr,true);
> > matchdeclare(aa,true);
> > matchdeclare(bb,true);
> > matchdeclare(ss,true);
> > matchdeclare(tt,true);
> >
> > defmatch(Jp,J(rr,aa,bb,ss,tt));
> >
> > isJp : lambda([x],is(Jp(x) # false));
> >
> > matchdeclare(JJ,isJp);
> > matchdeclare(ff,true);
> >
> > defmatch(SJp,ff*JJ);
> >
> > Jparts : makelist(rhs(SJp(e2parts[i])[1]),i,1,length(e2parts));
> > -----------------------------------------------------------------------
> >
> > then Jparts is a list of the following form
> > -----------------------------------------------------------------------
> > [J(r,a+2,b,s+2,t),J(r,a+2,b,s+1,t+1),J(r,a+2,b,s,t+2), ... ]
> > -----------------------------------------------------------------------
> >
> > Sorting that list and finding the unique elements should be no problem.
> > The last step is then to extract the coefficients of the J-Terms.
> >
> > To split the linear combination I used expand with a combined makelist.
> >
> > Does somebody know perhaps of a faster solution?
> > The above took already 7s on my computer (2Ghz)
> >
> > Andre
> > _______________________________________________
> > Maxima mailing list
> > Maxima at math.utexas.edu
> > http://www.math.utexas.edu/mailman/listinfo/maxima
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima