Mathematica 9 is now available
Student Support Forum
Student Support Forum: 'Strange errors evaluating functions' topicStudent Support Forum > General > "Strange errors evaluating functions"

Next Comment >Help | Reply To Topic
Author Comment/Response
10/31/11 10:15am

I found this forum searching for some mathematica support fora, I hope it's the correct one for my question. I have to confess to not having throughly read Mathematica's manual, so my understanding of how functions work might be a problem here. This is what I'm trying to do:

Define a simple recursive function:

f[0, n_] := 1
f[1, n_] := 1/2
f[m_, n_] := (1/m) Coefficient[Sum[Sum[Sum[
1/((2*k)!)*i^(2 k)*1/(2 m - 2 k - 2)!*(n - j)^(2*m - 2*k - 2), {k, 0, m - 1}], {j, i + 1, n}], {i, 0, n}], n, 2*m]

The function should evaluate to 1/(2*m)!, it computes leading term of a recursively defined polynomial which is at this point irrelevant.
Indeed, Mathematica evaluates it as it should:

f[3, n]

Now I make two functions that use this one, in the first one I use f[m,n] explicitly and in the second one I substitute it with 1/(2*m)!

g[m_, n_] :=
i^(2 k)*(1/(2 m - 2 k - 2)!)*(n - j)^(2*m - 2*k - 2), {k, 0, m - 1}]^2, {j, i + 1, n}], {i, 0, n}], n, 4*m - 2]

h[m_, n_] :=
Coefficient[Sum[Sum[Sum[f[k, n]*i^(2 k)*f[2 m - 2 k - 2, n]*(n - j)^(2 m - 2 k - 2), {k, 0, m - 1}]^2, {j, i + 1, n}], {i, 0, n}], n, 4*m - 2]

The functions g and h are identical, only in one I write (1/(2*k)!) and in the other f[k,n]. One would expect the same result, but no:
g[2, n]

I suspect I am missing something about manipulating with variables and functions, but reading the help didn't help me so I'm asking here. Thanks!

URL: ,

Subject (listing for 'Strange errors evaluating functions')
Author Date Posted
Strange errors evaluating functions Rasto 10/31/11 10:15am
Re: Strange errors evaluating functions Rasto 11/01/11 3:04pm
Next Comment >Help | Reply To Topic