[seqfan] Fwd: Re: A000207: Maple-Program wrong
Maximilian Hasler
maximilian.hasler at gmail.com
Sun Apr 19 17:09:34 CEST 2009
Testing the code I notice that there was a problem with the offset,
which is corrected in the program below.
I understand that the " +1 -2 " pieces are reminiscent of the
formula, but IMO it would not be confusing to simplify it in the code.
Since the k was used only in one place, I replaced it by its value.
This gives the simplified version
A000207 := proc(n) local t;
if n mod 2 = 0 then t := A000108(n/2)/4 else t := 0 fi:
if n mod 3 = 1 then t := t + A000108((n-1)/3)/3 fi:
A000108(n)/(2*n+4) + t + A000108(floor(n/2))/2
end:
Maximilian
---------- Forwarded message ----------
From: Maximilian Hasler <maximilian.hasler at gmail.com>
Date: Sun, Apr 19, 2009 at 10:23 AM
Subject: Re: [seqfan] Re: A000207: Maple-Program wrong
To: Rainer Rosenthal <r.rosenthal at web.de>
Cc: njas at research.att.com, Richard Mathar <mathar at strw.leidenuniv.nl>
For me (using Maple 7) the program works except for n=1, where it
gives A108(-1), while this should give a "division by zero error".
One could implement that value as a special case,
and simplify the code :
* RETURN() is superfluous and might break compatibility to alter
Maple versions(*),
* calculation of A108 should not be done if the coefficient is zero,
* "option remember" seems not useful since there is no recursion.
(Do you really mean A207 ?) -- (*) this may be your problem
A000207 := proc(n) local k, it1, it2;
if n=1 then 1 else
k := floor(n/2)+1;
if n mod 2 = 0 then it1 := A000108(n/2+1-2)/4 else it1 := 0 fi:
if n mod 3 = 0 then it2 := A000108(n/3+1-2)/3 else it2 := 0 fi:
A000108(n-2)/(2*n) + it1 + A000108(k-2)/2 + it2
fi
end:
Maximilian
More information about the SeqFan
mailing list