2

I have the following definition:

o[a_] := Sum[  x^(2 k + 1) Product[(2 i + 1)^2 - a^2, {i, 0, 
  k - 1}]/((2 k + 1)!), {k, 0, Infinity}]

Now when I evaluate

o[1]
(* 0 *)

Which I don't believe is correct. Also, changing the definition to

o[a_] := Sum[  x^(2 k + 1) Product[(2 i + 1)^2 - a^2, {i, 0, 
  k - 1}]/((2 k + 1)!), {k, 0, 1000}]

Or some other large number it does yield the correct result: $x$.

So am I overlooking something here and does this make sense, or is this a bug?


To be clear, here is my reasoning for why is should be $x$:

$$o(1)=\frac{x}{1!}\prod_{i=0}^{-1}((2i+1)^2-1)+\frac{x^3}{3!}\prod_{i=0}^{0}((2i+1)^2-1)+\frac{x^5}{5!}\prod_{i=0}^{1}((2i+1)^2-1)+....$$ And here the product in the first term is empty, so evaluates to $1$, and all other products have a factor $1^2-1=0$, so they all evaluate to $0$. So in total the result will just be $x$.


So is it fair to say this is a bug?

Szabolcs
  • 234,956
  • 30
  • 623
  • 1,263
user2520938
  • 163
  • 5
  • I think o[1]=0 is correct (nice choice of function name btw ;). You have a product that starts at i=0 and when i=0 and a=1 you get Product[1^2-1] for the first element, which is zero. Hence the whole product becomes zero, since zero times anything is zero. Then the sum of zeros is zero. – Nasser Mar 23 '15 at 11:14
  • @Nasser No, in the first term of the sum the product runs from $i=0$ to $i=k-1=-1$, which is empty, and thus should be one. Multiplied by $x^{2k+1}=x$, this should return $x$. All other terms do have this $0$ term in the product you describe and thus will all be $0$. So in total the single $x$ should be the result – user2520938 Mar 23 '15 at 11:17
  • Well I'm not sure exactly what you mean, but can this theory of yours also explain the difference between summing to $\infty$ and summing to say $1000$? – user2520938 Mar 23 '15 at 11:21
  • I tried it on Maple, and it also gave zero. Screen shot: Mathematica graphics so this means it is highly unlikely the result by Mathematica is wrong. – Nasser Mar 23 '15 at 11:34
  • @Nasser Can you take a look at my edit and tell me if something is not correct? Again, maybe I'm just overlooking something here. – user2520938 Mar 23 '15 at 11:38
  • As for the second case, Mathematica result is not the same as Maple. Maple also gave zero. Screen shot: Mathematica graphics so there is possibility Mathematica result is wrong for the second case. – Nasser Mar 23 '15 at 11:39
  • The problem seems to be in the generic symbolic Product[(2 i + 1)^2 - 1^2, {i, 0, k - 1}] vs. specific numeric ones, Table[Product[(2 i + 1)^2 - 1^2, {i, 0, k - 1}], {k, 0, 3}]. – Michael E2 Mar 25 '15 at 03:15
  • @MichaelE2 Yes I think it does a bit premature optimization by just assuming the $k-1$ will be $\geq 0$, while that of course need not be the case – user2520938 Mar 25 '15 at 09:34
  • Please do not add the bugs tag to new questions you posted. It is meant to be added later, after it is confirmed by the community. This is mentioned in the description of the tag. – Szabolcs Mar 26 '15 at 17:13
  • I would not consider the fact that Product[x, {x, 0, a}] evaluates to 0 a bug. – Szabolcs Mar 26 '15 at 17:15
  • Consider Product[x, {x, 0, a}, GenerateConditions -> True] to see how Product treats a symbolic product (from the docs: "The upper product limit is assumed to be an integer distance from the lower limit"). – Michael E2 Mar 26 '15 at 18:14

2 Answers2

1

If you evaluate the term first, the result is

Sin[a ArcSin[x]]/a

which, when assigned to o[a_], will further evaluate to x for o[1].

So, the solution to your problem would be to

  1. Evaluate the term
  2. Then define o[a_] on the result.
Jinxed
  • 3,753
  • 10
  • 24
  • Sorry but I'm quite getting what you mean. I see that it evaluates to the expression, but I don't understand how that causes these problems? Shouldn't filling in $a=1$ in my definition that still evaluate to $\frac{\sin (1\arcsin x)}{1}=x$? – user2520938 Mar 23 '15 at 11:49
  • @user2520938: I would think so, too, but alas, it doesn't. As soon as SetDelayed is involved, the output seems messed up. I tried o[a_,kmax_,x_]=... (resulting in a longer expression) and then tried o[1,kmax,x], but this yields indeterminate expression errors. At the moment, my answer seems the only way to go. – Jinxed Mar 23 '15 at 11:54
  • Oke thanks for your time and answer. I'll just use this solution for now. I won't accept the answer just yet, because I'm curious for more input on this. – user2520938 Mar 23 '15 at 11:57
  • @user2520938: Good idea, because there are people around here, who are much more knowledgeable on Mathematica than I am. Maybe you also found a bug. – Jinxed Mar 23 '15 at 12:04
0

Amplifying on @Jinxed answer:

$Version

"10.0 for Mac OS X x86 (64-bit) (December 4, 2014)"

o[a_] := Sum[
  x^(2 k + 1) Product[(2 i + 1)^2 - a^2, {i, 0, 
      k - 1}]/((2 k + 1)!), {k, 0, Infinity}]

o[a]

Sin[a*ArcSin[x]]/a

o[0]

ArcSin[x]

Limit[o[a], a -> 0]

ArcSin[x]

o[0] // Trace

enter image description here

term[k_] = 
 x^(2 k + 1) Product[(2 i + 1)^2 - a^2, {i, 0, k - 1}]/((2 k + 1)!) //
   FullSimplify

(4^k*x^(1 + 2*k)Cos[(aPi)/2]Gamma[1/2 - a/2 + k] Gamma[(1 + a)/2 + k])/(Pi*Gamma[2 + 2*k])

o2[a_] = Sum[term[k], {k, 0, Infinity}] // FullSimplify

Sin[a*ArcSin[x]]/a

Limit[o2[a], a -> 0]

ArcSin[x]

Bob Hanlon
  • 157,611
  • 7
  • 77
  • 198