Mar 14, 2010

dsum : Sum over divisors

This article demonstrates the defining of dsum, sum over divisors on given number N. As before, the tex output definition is also presented using texput(). Few of the trivial examples are given, too.

Maxima 5.20.0 http://maxima.sourceforge.net
using Lisp CMU Common Lisp 19f (19F)
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
The function bug_report() provides bug reporting information.
(%i1) block(load(("/Users/yasube/Programming/imaxima-imath/imaxima.lisp")), linenum:0)$

(%i1) kill(all);


(%i1) dsum(exp, var, N) ::=
if integerp(N)
then buildq([exp:exp,var:var,N:N],block([res:0,divlist:listify(divisors(N))], for var in divlist do res:res+exp, return(res)))
else apply(nounify(dsum),[exp,var,N])$

(%i2) texput(nounify(dsum),
lambda([arglist], block([e,v,pm],[e,v,pm]:args(arglist),
concat("\\sum_{",tex1(v) ,"|",tex1(pm),"}",tex1(e)))))$

(%i3) texput(moebius, "\\mu")$

(%i4) "A couple of examples of dsum()"$

(%i5) 'divisors(36)=divisors(36);


(%i6) 'dsum(d,d,36)=dsum(d,d,36);


(%i7) 'divisors(20)=divisors(20);


(%i8) 'dsum(f(d),d,20)=dsum(f(d),d,20);


(%i9) exp1:sum(f(n)/n^s,n,1,inf)*sum(g(n)/n^s,n,1,inf)=sum(dsum(f(d)*g(n/d),d,n)/n^s,n,1,inf);


(%i10)

No comments:

Post a Comment