request for comments/improvements/style of first Maxima script



On Wed, Jan 09, 2008 at 02:54:50PM -0500, Stavros Macrakis wrote:
> 
> Thanks for sharing your source with us.
> Here's how I would do it:
>
>    P(x, n) := bernpoly(x, n+1)/(n+1)!$
>    phi[i,s,alpha] :=
>      if i=0 then product(x[i]^5,i,1,s)
>      else
>       phi[i-1,s,alpha]
>          +
>       sum(
>           sum( (-1)^ni * P(x[i],ai) * subst( x[i]=ni,
>    diff(phi[i-1,s,alpha], x[i], ai) ),
>                ni, 0, 1),
>           ai, 0, alpha-1)$
>    phi[2,2,2];  =>
>    x[1]^5*x[2]^5-5*(x[1]^2-x[1]+1/6)*x[2]^5/2-(x[1]-1/2)*x[2]^5
> 
>    -(5*x[1]^5-25*(x[1]^2-x[1]+1/6)/2-5*(x[1]-1/2))*(x[2]^2-x[2]+1/6)/2
>                       -(x[1]^5-5*(x[1]^2-x[1]+1/6)/2-x[1]+1/2)*(x[2]-1/2)
>
>    Notice that phi does not have an (x) argument -- it is not needed, we
>    simply manipulate *expressions*.  Also, no loop is needed: recursion
>    with memoizing is enough.  Finally, I have added s and alpha as
>    subscripts to phi so that the same run can have different values of s
>    and alpha without running into the memoizing issue I mentioned
>    earlier.

Thanks.  While slightly adapting your version and playing around
with it, i noticed a difference in behavior between your version
and mine when for example the dimension s is larger than one.

The function that I create has a special property that I have
added at the end of the postscript which can be found online at

http://www.cs.kuleuven.be/~bartv/stuff/bernoulli/periodizing_with_bernoulli_polynomials.ps

Now both your and my script that implement this can be found at

http://www.cs.kuleuven.be/~bartv/stuff/bernoulli/

Notice that the integral for the function (x[1]*x[2])^2 in two
dimensions is 1/9.  For alpha large enough (i take it 5 in the
scripts, which should be ok) we then have that the newly
constructed function should also exactly be this value of 1/9.

Your script seems to show that result.  My script however does
not.  It gives a value of 1/25 instead of 1/9 and I cannot see
what I am doing wrong.

Does anybody see what I'm doing wrong in my script

http://www.cs.kuleuven.be/~bartv/stuff/bernoulli/method_with_bernoulli_polynomials.mac

compared to the apparently correct functioning script

http://www.cs.kuleuven.be/~bartv/stuff/bernoulli/method_with_bernoulli_polynomials2.mac

based on Stavros' method?

Thanks!
Bart

-- 
	"Share what you know.  Learn what you don't."