Summation bug? (HP-49G, 50g)
01-13-2015, 07:06 PM
Post: #1
 Gerson W. Barbosa Senior Member Posts: 1,138 Joined: Dec 2013
Summation bug? (HP-49G, 50g)
The HP-49G and HP-50g give wrong answers or error messages depending on the setting of flag -22 (infinite result) when the argument is zero. The HP-48g returns 1 as expected ( cos(0) = 1 ). When x = 0 the summation evaluates to 1.13518518518E498 on the HP-49G/50g, instead of zero. Am I missing something here? Thanks!

HP-50g:

Code:
 %%HP: T(3)A(R)F(.); \<< RCLF -17. SF SWAP \-> x 'COS(\v/3./3.*(x+x^9./(32.*9.!)-\GS(k=2.,4.,x^(2.*k-1.)/(5.*(2.^k-1.)*(2.*k-1.)!))))' EVAL SWAP STOF \>>

HP-48:

Code:
 %%HP: T(3)A(D)F(.); \<< RCLF -17 SF SWAP \-> x 'COS(\v/3/3*(x+x^ 9/(32*9!)-\GS(k=2,4,x ^(2*k-1)/(5*(2^k-1) *(2*k-1)!))))' EVAL SWAP STOF \>>
01-13-2015, 09:25 PM
Post: #2
 Thomas Klemm Senior Member Posts: 1,449 Joined: Dec 2013
RE: Summation bug? (HP-49G, 50g)
Is this the expression you want to calculate?

$\cos(\frac{\sqrt{3}}{3}(x+\frac{x^9}{32\cdot9!}-\sum_{k=2}^{4}\frac{x^{2k-1}}{5(2^k-1)(2k-1)!}))$

(01-13-2015 07:06 PM)Gerson W. Barbosa Wrote:  The HP-48g returns 1 as expected ( cos(0) = 1 ).

That should be the correct result.

I have no idea what happens when using the HP-50g.

Cheers
Thomas
01-13-2015, 09:40 PM
Post: #3
 Claudio L. Senior Member Posts: 1,507 Joined: Dec 2013
RE: Summation bug? (HP-49G, 50g)
It seems the term x^(2*k-1) is evaluated by the sum function as x^(2*k)*x^(-1). This can be seen if you enter the summation alone, leave x undefined and press EVAL.
You end up with terms x^M/(C*x).
After that, numeric evaluation will attempt to do a division by zero, hence your infinite result.
Perhaps if you try a round of symbolic simplification before attempting to do the numeric EVALuation.
01-13-2015, 09:54 PM
Post: #4
 Claudio L. Senior Member Posts: 1,507 Joined: Dec 2013
RE: Summation bug? (HP-49G, 50g)
Apparently, the summation is done in "approx" mode even with the calculator in exact mode, so the exponents of x as well as the constants after the summation are real numbers, then the CAS is unable to simplify x^N/x.
Manually editing the result of SUM to change all reals into integers then EVAL in exact mode will finally get rid of the spurious x in the denominator.

I don't know if SUM is supposed to do this or not, but it's certainly an unexpected behavior, not very user-friendly.

Claudio
01-13-2015, 10:13 PM
Post: #5
 Gerson W. Barbosa Senior Member Posts: 1,138 Joined: Dec 2013
RE: Summation bug? (HP-49G, 50g)
(01-13-2015 09:25 PM)Thomas Klemm Wrote:  Is this the expression you want to calculate?

$\cos(\frac{\sqrt{3}}{3}(x+\frac{x^9}{32\cdot9!}-\sum_{k=2}^{4}\frac{x^{2k-1}}{5(2^k-1)(2k-1)!}))$

(01-13-2015 07:06 PM)Gerson W. Barbosa Wrote:  The HP-48g returns 1 as expected ( cos(0) = 1 ).

That should be the correct result.

I have no idea what happens when using the HP-50g.

Cheers
Thomas

Yes. This is a remarkable approximation of the sinc function, albeit in a limited range:

http://www.wolframalpha.com/input/?i=plo...283%29%2F3

I have no idea why this works, however. Apparently the first four terms are correct. The last term was chosen somewhat arbitrarily to adjust the results to their correct 12 digits.

Interestingly the HP-50g, unlike the HP-48, doesn't handle that summation when x = 0.

Cheers,

Gerson.
01-13-2015, 10:26 PM
Post: #6
 Gerson W. Barbosa Senior Member Posts: 1,138 Joined: Dec 2013
RE: Summation bug? (HP-49G, 50g)
(01-13-2015 09:54 PM)Claudio L. Wrote:  Apparently, the summation is done in "approx" mode even with the calculator in exact mode, so the exponents of x as well as the constants after the summation are real numbers, then the CAS is unable to simplify x^N/x.
Manually editing the result of SUM to change all reals into integers then EVAL in exact mode will finally get rid of the spurious x in the denominator.

I don't know if SUM is supposed to do this or not, but it's certainly an unexpected behavior, not very user-friendly.

Claudio

Thanks you very much for your analysis of the problem. I've tried both exact and approximate modes and a combination of flag settings to no avail. This is not the first time I had trouble with summation on the 50g, problems the HP-48 didn't have. The last one was indeed a bug and has already been fixed.

Regards,

Gerson.
01-15-2015, 01:28 AM
Post: #7
 Thomas Klemm Senior Member Posts: 1,449 Joined: Dec 2013
RE: Summation bug? (HP-49G, 50g)
(01-13-2015 10:13 PM)Gerson W. Barbosa Wrote:  I have no idea why this works, however. Apparently the first four terms are correct. The last term was chosen somewhat arbitrarily to adjust the results to their correct 12 digits.

This is the Taylor-Series of $$\arccos(sinc(x))$$:
$\frac{1}{\sqrt{3}}(x-\frac{x^3}{90}-\frac{x^5}{4200}-\frac{x^7}{378000}+\frac{533 x^9}{6286896000}+\frac{2599 x^{11}}{454053600000}+\frac{75799 x^{13}}{572107536000000})+O(x^{14})$

The correct value is $$\frac{6,286,896,000}{533}=\frac{17,325\cdot9!}{533}\approx11,795,302.0638$$ instead of $$32\cdot9! = 11,612,160$$.
Thus instead of 32 the factor is $$\frac{17,325}{533}\approx32.5047$$.

Quote:This is a remarkable approximation of the sinc function
Now I hope it's clear why.

Cheers
Thomas
01-15-2015, 09:37 AM
Post: #8
 Gerson W. Barbosa Senior Member Posts: 1,138 Joined: Dec 2013
RE: Summation bug? (HP-49G, 50g)
(01-15-2015 01:28 AM)Thomas Klemm Wrote:
(01-13-2015 10:13 PM)Gerson W. Barbosa Wrote:  I have no idea why this works, however. Apparently the first four terms are correct. The last term was chosen somewhat arbitrarily to adjust the results to their correct 12 digits.

This is the Taylor-Series of $$\arccos(sinc(x))$$:
$\frac{1}{\sqrt{3}}(x-\frac{x^3}{90}-\frac{x^5}{4200}-\frac{x^7}{378000}+\frac{533 x^9}{6286896000}+\frac{2599 x^{11}}{454053600000}+\frac{75799 x^{13}}{572107536000000})+O(x^{14})$

The correct value is $$\frac{6,286,896,000}{533}=\frac{17,325\cdot9!}{533}\approx11,795,302.0638$$ instead of $$32\cdot9! = 11,612,160$$.
Thus instead of 32 the factor is $$\frac{17,325}{533}\approx32.5047$$.

Quote:This is a remarkable approximation of the sinc function
Now I hope it's clear why.

It is crystal clear now!

Thank you very much!

Gerson.
 « Next Oldest | Next Newest »

User(s) browsing this thread: 1 Guest(s)