> I see, really nice - but don't know why it does not work...
>
> (%i2) abl(f,x) := COEFF(f,x,HIPOW(f,x))*HIPOW(f,x)*x^(HIPOW(f,x)-1);
> HIPOW(f, x) - 1
> (%o2) abl(f, x) := COEFF(f, x, HIPOW(f, x)) HIPOW(f, x) x
> (%i3) declare(abl,additive);
> (%o3) DONE
> (%i4) abl(5*x^2+2*x,x);
> (%o4) 10 x
Because abl() is evaluated before the additive rule is applied.
One way to work around this is to declare abl as a noun before declaring it
additive (the order of the two declare's is important):
(%i1) abl(f,x):=coeff(f,x,hipow(f,x))*hipow(f,x)*x^(hipow(f,x)-1);
hipow(f, x) - 1
(%o1) abl(f, x) := coeff(f, x, hipow(f, x)) hipow(f, x) x
(%i2) declare(abl,noun);
(%o2) done
(%i3) declare(abl,additive);
(%o3) done
(%i4) abl(5*x^2+2*x,x);
2
(%o4) abl(5 x , x) + abl(2 x, x)
But of course this is not exactly what you want, since you DO want abl()
evaluated eventually. So tell the simplifier (there may be a more elegant
way to do this, but this is what I could think of right now):
(%i5) matchdeclare([dummy1,dummy2],true);
(%o5) done
(%i6) tellsimpafter(abl(dummy1,dummy2),ev(abl(dummy1,dummy2),abl));
(%o6) [ablRULE1, simpargs1]
(%i7) abl(5*x^2+2*x,x);
(%o7) 10 x + 2
Viktor