Two identical computations give different results?

I added a notebook but the preview looks unreadable. The notebook shows two seemingly identical computations giving different answers. I’m posting to see if the post is readable. If so, perhaps someone could comment.

Thanks,
Leon

Bug.nb (4.57 KB)

Try a fresh restart of Mathematica to clear the hidden cache of previous work and then

In[1]:= Clear["`*"];
p0[i_]:=Sum[(-1)^j 2^(2j-2)(Binomial[i+j-2,2j-2](2i-1)/(2j-1)),{j,1,i}]
p[i_,x_]:=Sum[(-1)^j 2^(2j-2)(Binomial[i+j-2,2j-2](2i-1)/(2j-1))x^(2j-1),{j,1,i}]
p0[3]
p[3,1]

Out[4]= -1

Out[5]= -1

Check this very carefully to make certain I haven’t made any mistake.

And then the hard part, see if you can remember and reproduce what you might have done to get the different result and figure out why that gave you the different result. IF you can successfully do that then that might help protect you in the future when it isn’t as obvious that a result isn’t what it should be. That is what the outcome of this really should be. I hope it works.

You were right. After restarting Mathematica and executing the Clear the two formulas agreed. I will continue to investigate. Thanks!

I think I may know what caused the problem. Usually, I set the notebook’s default context to “unique to this notebook”. I left one notebook in global context. That notebook had a different formula for p(x) than the one in the new notebook.

I am VERY impressed! I thought it might likely be the case that you would never be able to track down the real reason for this. You taught me and you and perhaps others one more thing to watch out for. Congratulations and thank you.

You are very generous. I have you to thank for resolving this. Thank you.