Sin(Pi) in Radians Mike Posting Freak Posts: 899 Threads: 193 Joined: Jan 2005 08-27-2004, 08:21 AM I know the sine of pi in radians should be zero. However, 41CX -4.100 E-10 20S -2.067 E-13 30S 0.000 E00 I undererstand it has something to do with rounding, but the 30 does not calculate pi to infinity, does it round the answer instead? What about other models? John Limpert Member Posts: 172 Threads: 13 Joined: Jul 2005 08-27-2004, 08:39 AM On the HP-28C and HP-48GX, sin(pi) results in zero (exactly). Bram Member Posts: 182 Threads: 17 Joined: Oct 2005 08-27-2004, 08:56 AM 11C: same answer as 41CX 32SII: same as 20S 29C: same as 20S 21: same as 30S (answer is correct: 0) Yhis last bit surprises me, because it fails to compute 2^30 correctly and almost all its successors are right on that point. Edited: 27 Aug 2004, 12:45 p.m. after one or more responses were posted JMH Junior Member Posts: 1 Threads: 0 Joined: Jan 1970 08-27-2004, 09:21 AM HP 97 same as the 41 and 11C -4.100 E-10 Barry Schwartz Junior Member Posts: 8 Threads: 0 Joined: Jan 1970 08-27-2004, 01:09 PM In the manual for the 15C, it is explained that the value returned by using the PI key on the calculator is good to 10 significant digits. Thus the value returned for sin(PI) is the same as for the 41CX since it is the sin of a 10 digit approximation to PI rather than PI itself. Some calculators carry more than 10 digits in their calculations and thus will produce sin(PI) = 0 when they round to 10 digits. For example, the TI-83 produces sin(PI)=0 because it carries internal calculations to 14 digits. If one calculates sin(PI) on the TI-83 with the same 10 digit approximation used on the 15C, then the same result as the 15C is generated. Trent Moseley Senior Member Posts: 406 Threads: 47 Joined: Jul 2005 08-27-2004, 02:37 PM Of all the different calcs that I have only the 25C and the 31E give exactly zero. tm James M. Prange (Michigan) Posting Freak Posts: 1,041 Threads: 15 Joined: Jan 2005 08-27-2004, 03:48 PM Yes, on the RPL calculators, replacing 'SIN(pi)' by 0 is one of the many built-in simplifications, as long as pi is symbolic. Of course, evaluating SIN(3.14159265359) quite correctly returns a non-zero result. To get the 0, clear both flag -2 (Constant -> symb) and flag -3 (Function -> symb). Regards,James Gordon Dyer Senior Member Posts: 331 Threads: 47 Joined: Oct 2005 08-27-2004, 04:43 PM Here are my results: HP-45 sin(pi)= 0.000000000 HP-11C, HP-41CV, HP-41CX, V41 sin(pi)= -4.10E-10 HP-20S, 21S, 22S, 32SII, 42S, 71B sin(pi)= -2.06761537357E-13 HP-30S sin(pi)= 0 Casio fx-450 sin(pi)= 0 Commodore SR4912 sin(pi)= 0 Emmanuel, France Senior Member Posts: 280 Threads: 38 Joined: Jan 1970 08-27-2004, 05:28 PM ```Casio FX-880P : 0 Sharp PC-1261 : 0 TI-59 : 0 HP-31E : -4,1000 -10 Elektronika MK-52 : 0 ``` Wlodek Mier-Jedrzejowicz Member Posts: 88 Threads: 8 Joined: Jul 2007 08-27-2004, 10:36 PM How about approaching this as a mathematical problem? sin (pi-delta) = sin (delta) If delta is small and in radians then sin (delta) = delta, to a very good approximation. Now, no calculator can store pi completely accurately, there is always a difference "delta" between pi to the number of digits that the calculator uses and the true value. So, any calculator that does not round, or treat pi as a symbolic value, should give the answer sin (pi) = delta, where delta is this rounding error. Those calculators that do give zero are doing one of the following: Treating "pi" as a symbolic value, and recognizing that sin (pi) is exactly zero, _not_ calculating sin (pi). That is what HP's RPL calculators do in symbolic mode. Obtaining a non-zero value, but then displaying zero because of the display mode chosen (I am sure that is what gave zero for people who reported it on models such as the HP-31E or the HP20S). Rounding a small value to exactly zero. Some calculators do this "unthinkingly", which is Bad News, since many other calculations give small but non-zero values. That is why HP calculators do not round. Other calcs have code built in to recognize that certain types of calculation can reasonably be rounded, for example if an integer is followed by a string of zeros, and then a very small value. Casio and TI routinely do this sort of thing. The HP30S works to very high precision (almost 30 digits, it has been reported) and is more justified than most in rounding extremely small results to zero. There is one other possibility - that in the formulae I gave above delta is zero to the precision of the calculator. If you evaluate pi to enough significant digits, this will eventually happen. Just wait for calculators that work to, oh, a million or more significant figures... ;-) Hope this helps! Wlodek Palmer O. Hanson, Jr. Posting Freak Posts: 901 Threads: 113 Joined: Jun 2007 08-27-2004, 11:09 PM More on funny arithmetic On an HP-41 in radian mode: sin (pi) = - 4.1E-10 sin (-pi) = + 4.1E-10 sin (pi/4) - cos (pi/4) = 2.0E-10 On an HP-41 in degree mode: sin (180) = 0 sin (-180) = 0 sin (45) - cos (45) = 0 On a TI-59 in radian mode sin (pi) = 0 sin (-pi) = 0 sin (pi/4) - cos (pi/4) = 7.0E-13 On a TI-59 in degree mode: sin (180) = 0 sin (-180) = 0 sin (45) - cos (45) = 7.0E-13 On a TI-59: (pi x e) - (e x pi) = pi x 1 INV lnx - 1 INV lnx x pi = -2.8E-11, but pi / 1 INV lnx 1/x - 1 INV lnx x pi 1/x = -1.0E-12 It's enough to make one want to go back to one's slide rule where one KNEW that three digit accuracy was about the best one could do. J-F Garnier Senior Member Posts: 412 Threads: 40 Joined: Mar 2006 08-28-2004, 05:31 AM Actually, all Saturn-based machines know the pi value with double precision, and it's easy to get the extra pi digits thanks to the non-rounding behavior: SIN(3.1415926535) gives 8.97932384626e-11, which are the next pi digits: pi=3.1415926535897932384626... J-F Jordi Hidalgo Member Posts: 50 Threads: 4 Joined: Jan 1970 08-28-2004, 12:28 PM On the HP 9s, the sine of a number x such that 3.1415926535 <= x <= 3.1415926536 is zero in Radian mode. IMHO this is not fudging, but a way of using (defining) an irrational number by implementing one of its most important properties, namely: that its sine must be zero. And the same goes for the 9g and the 30S, with different intervals, though. Jordi Vieira, Luiz C. (Brazil) Posting Freak Posts: 4,027 Threads: 172 Joined: Aug 2005 08-28-2004, 01:42 PM Hello Wlodek, guys; just one single question, "bitte". I remember, when studying Calculus (long time ago), that: `sin(delta) = delta` but I cannot help remembering the math considerations/approaches and to what extent `sin(delta) = delta` I mean, how small should delta be so it is true. If `sin(delta) = delta` is true, then sin(delta) becomes a straight line and it cannot be asymptotic. Is it a math consideration or a numerical approach, what is, in fact, closer to computers? Just a doubt of mine. Cheers. Luiz (Brazil) hugh steers Senior Member Posts: 536 Threads: 56 Joined: Jul 2005 08-28-2004, 04:07 PM as you know, when you press pi on your hp then sin, most models return a non-zero answer. the manuals rather smugly point out that the answer returned is exactly the right answer for the pi approximation used by the machine. you know this. but, here is my swift kick in the pants for hp: how about getting the right answer for large arguments. for example, the 48gx gives sin(1e50) = 0.08683927... which is *completely* wrong, the correct answer being, -0.7.8967249342931008271028953... so there. Mike Posting Freak Posts: 899 Threads: 193 Joined: Jan 2005 08-28-2004, 05:11 PM sin is an offense to God, not HP, sine is something different Tizedes Csaba [Hungary] Member Posts: 97 Threads: 25 Joined: Jan 1970 08-28-2004, 05:18 PM Dear Luiz, I hope I understood your question correctly. ```The Taylor-serie is: f(a+delta)=f(a)+ (n=0) f'(a)*delta/1!+ (n=1) f''(a)*(delta)^2/2!+ (n=2) f'''(a)*(delta)^3/3!+... (n=3, ...) Then we approximate f(x)=SIN(x), at a=0: --------------------------------- f(x)= SIN(x) and f(a)= 0 f'(x)= COS(x) and f'(a)= 1 f''(x)= -SIN(x) and f''(a)= 0 f'''(x)= -COS(x) and f'''(a)= -1 --------------------------------- f''''(x)=SIN(x), and so on... So, f(a+delta)==SIN(a+delta)==SIN(delta)=delta-(delta)^3/6+-... And we want to use this serie with n=1: SIN(delta)=delta+Rn(delta), where Rn(delta) is the residual: Rn(delta)=(delta-a)^(n+1)/(n+1)!*f[n+1](ksi), where f[n+1](ksi) is the (n+1)'th derivative of f(x) at ksi, where a<=ksi<=delta Use it, and find the maxima of Rn(delta): (n=1) Rn(delta)=(delta)^2/2!*f''(ksi), if we want to maximize it, we must to use f''(ksi)=1: so, let eps is the "precision of calculator": 1+eps<>1, we get: ########################################### # # # eps>=delta^2/2 --> delta<=SQRT(2*eps) # # # ########################################### On HP32SII: eps=5E-12, we get delta<=3.16E-6, and with simple trying I get delta=3.11E-6 ``` Best wishes: Csaba Edited: 28 Aug 2004, 5:22 p.m. Dave Shaffer (Arizona) Posting Freak Posts: 776 Threads: 25 Joined: Jun 2007 08-28-2004, 05:56 PM Note, also, that lim [sin(x)/x] = 1 as x-> 0 In other words, it IS linear the closer you get to zero. Dave Shaffer (Arizona) Posting Freak Posts: 776 Threads: 25 Joined: Jun 2007 08-28-2004, 06:02 PM Hugh, re: "the 48gx gives sin(1e50) = 0.08683927... which is *completely* wrong, the correct answer being, -0.7.8967249342931008271028953..." Unless you are doing arithmetic to 50 digits, the poor calculator can't do this correctly. Without checking any actual algorithms, I strongly suspect that any calculator has to basically do MOD arithmetic to determine how many complete turns it has to subtract from x, and then determine the sine of the leftover. If the number of (implied) digits exceeds the calculator's number of sig figs, then the answer will be wrong. Your 1e50 means the calculator has to do 50 digit math to get the correct modulo remainder. Garth Wilson Posting Freak Posts: 887 Threads: 9 Joined: Jul 2007 08-28-2004, 06:12 PM > It's enough to make one want to go back to one's slide rule where one KNEW that three digit accuracy was about the best one could do. The 3-4 digits of the slide rule were usually adequate for real applications too. Trying to guess at the width of the hairline impressed upon us how insignificant further digits really were. Without that reference, people now use a calculator with 10 digits or more, and are not satisfied that accuracy does not always match the extreme precision. Short of positioning a satelite, I can't think of anything that has any use for that many digits. Garth Wilson Posting Freak Posts: 887 Threads: 9 Joined: Jul 2007 08-28-2004, 06:17 PM To really understand what's going on, sometimes it's better to scrap all the mathematical proofs and just draw, in this case a right triangle with a very slim angle. You'll also see that as the angle approaches zero, the tangent will be the same as the sine. The equations are much more meaningful after we understand what they're representing. Vieira, Luiz C. (Brazil) Posting Freak Posts: 4,027 Threads: 172 Joined: Aug 2005 08-28-2004, 06:17 PM Hi, guys; I saw your post, Tizedes, and the Taylor-Series considerations brought some memories back... Thanks! Also, Dave's remark about the limits is precise: (sin(X))/X tends to be a straight line as X gets closer to zero. So, both numerical and analytical ways lead to a common situation. Thanks! This is the kind of thread that worth reading head to tail. Luiz (Brazil) Edited: 28 Aug 2004, 6:18 p.m. Tizedes Csaba [Hungary] Member Posts: 97 Threads: 25 Joined: Jan 1970 08-28-2004, 06:22 PM . Edited: 28 Aug 2004, 7:07 p.m. John Limpert Member Posts: 172 Threads: 13 Joined: Jul 2005 08-28-2004, 07:27 PM It does bring up an issue with some implementations of trig. functions. Not all of them do a good job at range reduction. I ran across a mention of this problem while reading a book on computational astronomy (J. Meeus). The book uses the sine of 360000030 degrees as an example. The correct answer is 0.5. hugh steers Senior Member Posts: 536 Threads: 56 Joined: Jul 2005 08-28-2004, 08:02 PM not true. i had this problem already myself. you need a pi lookup table and you extract the appropriate 10 digit part (for 10 digit results). ok, you need to store the digits, but you dont need 50 digit math. Jordi Hidalgo Member Posts: 50 Threads: 4 Joined: Jan 1970 08-29-2004, 11:50 AM FWIW, here are the intervals around pi for which the sine function returns zero on the HP 30S: [3.141592653589793237976281, 3.141592653589793238945133] and on the HP 9g: [3.14159265358979323798, 3.14159265358979323894] Jordi Eddie Shore Senior Member Posts: 260 Threads: 40 Joined: Jan 1970 08-29-2004, 02:58 PM I get 8.68392788E-2 for the HP20S. My TIs 89T and 36X both return ERROR. Karl Schneider Posting Freak Posts: 1,792 Threads: 62 Joined: Jan 2005 08-29-2004, 04:07 PM J-F Garnier posted, Quote: Actually, all Saturn-based machines know the pi value with double precision, and it's easy to get the extra pi digits thanks to the non-rounding behavior: SIN(3.1415926535) gives 8.97932384626e-11, which are the next pi digits: pi=3.1415926535897932384626... Ya lost me, there. I cannot obtain this result on any Pioneer, or RPL-based (28/48/49) calc that I have. I get -2.0676157357 x 10^(-13) when taking sine of the 12-digit approximation of pi on these calc's. When I convert 'pi' to a number on the RPL models and start "chipping away" the digits (Frac part, 10x, etc...), I stil find that only 12 digits of accuracy are present. J-F Garnier Senior Member Posts: 412 Threads: 40 Joined: Mar 2006 08-30-2004, 06:39 AM Try SIN(3.1415926535), not SIN(3.14159265359) ... J-F gordon Junior Member Posts: 43 Threads: 10 Joined: Jan 1970 08-30-2004, 06:44 PM The HP-42S does give sin(360000030)=0.5 ! Palmer O. Hanson, Jr. Posting Freak Posts: 901 Threads: 113 Joined: Jun 2007 08-30-2004, 09:34 PM I recall that in my old pre-calculus courses such as advanced algebra and trigonometry where the concept of limits and Taylor series had hardly been introduced there was a drawing of a sector defined by a radius R at an acute angle theta from the x axis, the length R along the x axis, and the arc of length R times theta. Then a vertical line was drawn from the intersection of the radius with the arc downward to the x axis (length is R sin theta) and another vertical line was drawn from the point (R,0) upward to connect with the extension of the radius (length is R tan theta). In this diagram the arc length is "squeezed" between the R sin theta segment and the R tan theta segment as the angle is decreased, showing that as the angle approaches zero the sin theta and the tan theta approach the angle theta. It's a lot easier to draw that than to write it, but I haven't learned how to post drawings. Palmer O. Hanson, Jr. Posting Freak Posts: 901 Threads: 113 Joined: Jun 2007 08-30-2004, 11:21 PM You state "Rounding a small value to exactly zero. Some calculators do this "unthinkingly", which is Bad News, since many other calculations give small but non-zero values. That is why HP calculators do not round. Other calcs have code built in to recognize that certain types of calculation can reasonably be rounded, for example if an integer is followed by a string of zeros, and then a very small value. Casio and TI routinely do this sort of thing." I am fairly familiar with the TI product line but not familiar with that. I know that the HP product carried guard digits and rounded results to ten digits. I also know that the TI product line routinely carried more digits in its results than were available in the display and rounded to the display. The internal results were typically truncated not rounded. TI switched to rounded internal results somewhere in the 1980's with the introduction of the TI-68 and TI-95. Can you give me some specific examples of the rounding that you describe? Karl Schneider Posting Freak Posts: 1,792 Threads: 62 Joined: Jan 2005 08-31-2004, 01:06 AM J-F -- Mea culpa! OK, now I'm getting your results on the Saturn-based machines I mentioned in my last post. I had failed to follow your instructions exactly. In fact, it can be taken one digit further: ```sin (3.14159265358) = 9.79323846264 E-12 = 0.00000000000979323846264 ``` However, I believe that your mild "contradiction" of Wlodek: Quote: Actually, all Saturn-based machines know the pi value with double precision... is not strictly correct. This exercise proves only that the Saturn-based HP calculators' algorithm for sine can be used to calculate 12 additional significant digits of pi. It does not prove that the machines "know" the value of pi to 24 significant digits. As Wlodek stated, Quote: sin (pi-delta) = sin (delta) If delta is small and in radians then sin (delta) = delta, to a very good approximation. So, when the first N correct digits of pi are entered in "radians" mode, the sine function will yield the next 12 missing digits accurately (for 7 <= N <= 12, as it turns out). That is, the machines will crunch out the Taylor series (or whatever method it uses) accurately to 12 sigificant digits. Since there is no range overlap between the input and the output for this problem, up to the 24th significant digit can be obtained. This indicates, to me, a well-written algorithm that minimizes roundoff error. The algorithm could be: ```sin (x) = x - x3/3! + x5/5! - x7/7! + ... = a0 - a1 + a2 - a3 + ... with a0 = x a1 = a0 * (x/2)*(x/3) a2 = a1 * (x/4)*(x/5) a3 = a2 * (x/6)*(x/7) ... ``` Good problem! -- KS Edited: 31 Aug 2004, 1:22 a.m. Jordi Hidalgo Member Posts: 50 Threads: 4 Joined: Jan 1970 08-31-2004, 07:10 AM Palmer O. Hanson, Jr wrote: Quote:Can you give me some specific examples of the rounding that you describe? He might be referring to this posting by John H. Meyers (also in Datafile V15N6p30). Jordi « Next Oldest | Next Newest »

 Possibly Related Threads... Thread Author Replies Views Last Post [OT] Mathematica free for Raspberry PI BruceH 32 3,737 11-23-2013, 05:24 AM Last Post: Nick_S Computing pi with the PC-1300S Kiyoshi Akima 0 487 11-17-2013, 12:24 AM Last Post: Kiyoshi Akima Calculating Pi LHH 9 1,318 09-27-2013, 10:50 PM Last Post: Gerson W. Barbosa Visualization of pi Bruce Bergman 13 1,720 08-17-2013, 05:00 PM Last Post: Howard Owen OT: Happy Pi Day! Eddie W. Shore 13 1,802 03-22-2013, 10:44 AM Last Post: Les Koller Totally OT ... Pi Day for my car Maximilian Hohmann 18 2,275 03-10-2013, 01:15 PM Last Post: chris smith [WP34S] A funny bug in Pi (prod) Eduardo Duenez 3 751 01-28-2013, 03:41 AM Last Post: Walter B 28S Pi Functionality Matt Fegenbush 3 741 10-17-2012, 02:15 AM Last Post: Nick_S e^pi - pi + 9/10^4 + 1/(10^4*ln(2) + sqrt(10)/6)^2 Gerson W. Barbosa 47 5,678 08-08-2012, 10:58 PM Last Post: Les Koller [OT] 355/113 and pi David Hayden 28 2,923 07-27-2012, 10:01 AM Last Post: Egan Ford

Forum Jump: