Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Question on Rads

21 views
Skip to first unread message

keir

unread,
Mar 8, 1997, 3:00:00 AM3/8/97
to

How come when I have my 48 in rads mode, and try to take the SIN of 2
Pi, I get the number 4.135E-13 and not Zero?


Al Arduengo

unread,
Mar 8, 1997, 3:00:00 AM3/8/97
to

keir wrote:
>
> How come when I have my 48 in rads mode, and try to take the SIN of 2
> Pi, I get the number 4.135E-13 and not Zero?
Because when you take the sin of 2Pi, Pi must be presented as a decimal
number which ultimately means error in the last fourteenth or fifteenth
digit. Thes, since the value of Pi's which is less than one has as yet
not been found (ie so far the decimal value has not repeated itself, the
48 must round off at the thirteenth digit, I believe.
In other words, it isn't exactly zero because you are not using exactly
Pi when you turn it into a number from the symbol.

Dick Smith

unread,
Mar 8, 1997, 3:00:00 AM3/8/97
to

In message <5frar8$8...@news.infoserve.net> keir wrote:

] How come when I have my 48 in rads mode, and try to take the SIN of 2
] Pi, I get the number 4.135E-13 and not Zero?

Not having an HP48 (yet) this is a bit worrying, as the TI-85 and various
other Casio-types give zero for this calculation.

Is this why TIs are preferred for education (because they get the answers
right) whereas HPs are used by engineers who are often quite happy with
'near-enough' type answers?

Dick


--
=============================================================================
Dick Smith Acorn Risc PC di...@risctex.demon.co.uk
=============================================================================


A Suehiro

unread,
Mar 9, 1997, 3:00:00 AM3/9/97
to

On Sat, 08 Mar 1997 18:09:11 +0100, di...@risctex.demon.co.uk (Dick
Smith) wrote:

>In message <5frar8$8...@news.infoserve.net> keir wrote:
>
>] How come when I have my 48 in rads mode, and try to take the SIN of 2
>] Pi, I get the number 4.135E-13 and not Zero?
>
>Not having an HP48 (yet) this is a bit worrying, as the TI-85 and various
>other Casio-types give zero for this calculation.
>
>Is this why TIs are preferred for education (because they get the answers
>right) whereas HPs are used by engineers who are often quite happy with
>'near-enough' type answers?

No,no,no, HPs actually calculate numbers with the _correct_ answer
given the number of digits of resolution (I actually read something
about this somewhere, anybody know of it?). Anyway HPs don't try to
predict that you *really* wanted pi or e or .3333333333333333333333...
so instead HP does all calculations within its resolution and rounds
at the end.

Calculators unlike real numbers have a finite resolution and anyone
worth listening to knows that you can't expect the results of finite
precision calculations to match those of infinite precision
calculations. Engineers are "happy" with 'near-enough' answers
because *we* understand the mathamatics of the problem and that at
some designated level of precision our answer is *good-enough*.

Who gives a damn if a TI calculates PI to 666 decimal places if all
you use in real life engineering problems is at most 6 or 7. But
since it has finite precision calculations, it must be lying to you.


==============================
Alan Suehiro
Digital Design Engineer
San Diego, CA
asue...@ix.netcom.com

John H Meyers

unread,
Mar 9, 1997, 3:00:00 AM3/9/97
to

In message <5frar8$8...@news.infoserve.net> keir wrote:
: How come when I have my 48 in rads mode, and try to take the SIN of 2
: Pi, I get the number 4.135E-13 and not Zero?

In article <19970308....@risctex.demon.co.uk>,
di...@risctex.demon.co.uk (Dick Smith) writes:

> Not having an HP48 (yet) this is a bit worrying, as the TI-85 and various
> other Casio-types give zero for this calculation.
> Is this why TIs are preferred for education (because they get the answers
> right) whereas HPs are used by engineers who are often quite happy with
> 'near-enough' type answers?

You have posted this spark onto a fairly flame-resistant group,
so here comes a cool answer :)

If there is a calculator which evaluates expressions completely in a
symbolic mode, then it might recognize sin(2*pi) as a symbolic expression
whose value should be zero; none of the calculators mentioned above has
such a capability, hence they all first evaluate the numeric argument
and then numerically calculate the sine of that argument.

As Al Arduengo pointed out; the numerically evaluated value of 2*pi
(to a finite number of decimal places) is not exactly two times pi,
so the sine of that number should not be expected to be exactly zero.

Nonetheless, some calculators, such as the Casio fx-6300G I happen to
have buried away in my desk for just such emergencies, do return zero
for this answer. Let's look a bit more closely at how Casio arrives
at this "cool" answer. First, let's see how well Casio calculates just
the 2*pi part of the problem, since "well begun is half done." When
I enter 2*pi-6.28318, the Casio responds with 5.3072E-6, which means
that this Casio calculated 2*pi to be 6.28318530720, which is its
full 12-digit internally stored value (before any rounding to its
standard 10-digit displayed value). Now, if pi is actually
3.14159 26535 89793 23846 26433 83279 50288... (which it is), then
2*pi is 6.28318 53071 79586 47692... Well, then, if we stop and
round this to 12 significant digits (which is the number of digits
which both the HP48 and the Casio fx-6300G keep in all of their
stored values), we should get 6.28318530718 ; hmm... it seems
to me that the Casio has already slipped a little bit off the
mark here, hasn't it? Meanwhile, back at the HP48, you do get
exactly what the 12-digit value should be, whether we calculate it
as 2*pi or as 360 D->R (the latter would be expected to be slightly
more accurate, but it so happens that either answer is the same).

Okay, now that we have established that half-way through our original
problem, the Casio has developed a slightly less accurate intermediate
result than the HP48, isn't it a marvel of science and engineering
how the Casio manages to come up with the pleasingly exact zero
final answer, whereas the HP48 comes up with that extremely
small non-zero answer which causes you to heap disdain upon those
casually stupid engineers at HP, who don't care about accuracy?

Without going into any deeper probe of the Casio calculator's amazing
abilities, I assert that in fact the Casio "fudges" its results to
appear to be what you expect of it, just as do so many students in all
the lab courses I have taken, whereas the HP faithfully and accurately
takes its given argument and returns an answer which is to 12 leading
significant digits (in scientific notation) the closest possible correct
answer for the non-zero numeric argument it was originally given.

If we express the given answer as a *fixed-point* value, then
its first 12 digits after the decimal point are all zero, which
ought to hint at the fact that this is actually a mighty accurate
correct answer, to the utmost limits of numerical computation
using scientific floating-point notation and 12 significant digits.

On 1996.09.04 I posted a lengthy analysis of how Casio delivers
"too good to be true" answers on many of its calculators
(TI also gets an honorable mention in the article for some of its
interesting gaffes from the distant past); if you are interested,
visit <http://xp1.dejanews.com/filter.xp?groups=comp.sys.hp48>
and type the words Casio and Fudge into the "search for" box;
then select my "Casio's Fudge exposed" article of that date.

Meanwhile, back to the students -- for purposes of education, we
often sugar-coat worldly realities for easier digestion by our
children and our students. If that is the preference, then
the models of calculator you mentioned are ideal for the purpose,
since they deliberately adjust and alter reality to make the
happy ending come out exactly as the storybook would have it.

If the facts about numerical methods in scientific and engineering
calculation be known, however, the most astute of engineers and
scientists well know that HP calculators have always gone to
extreme lengths to deliver the best overall accuracy that is
computationally possible -- better in fact than any other brand.

The only way to do better is to use more digits -- which of course
anyone can easily do using a variable-precision software package or
"unlimited-precision" integer arithmetic (perhaps the TI92 has this);
as far as common calculators go, however, HP is about as good
as you can possibly get.

The only areas I know of where HP seems not to have achieved perfection
in achievable accuracy are in some statistics and other functions which
the knowledgeable Bob Wheeler of ECHIP has pointed out, indicating that
there are newer methods which HP has not [yet] adopted. Nonetheless, Bob
says: "In spite of it all, HP is still the best by a long chalk. I bought
a TI85 out of curiosity -- its numerics are very very bad."

As a final curiosity, if 24-digit accuracy in all common arithmetic
(and square root) functions is of interest to you, see DIGI24 for the
HP48 on Goodies Disk #9 (math directory); it so happens that these
functions can only work on a calculator which has the extreme
precision of the HP48 to begin with; they evidently can not even
be made to work on any other brand of common calculator!

Cast your vote for honest, truthful calculators -- go for HP's !!

-----------------------------------------------------------
With best wishes from: John H Meyers <jhme...@mum.edu>

Hrair Mekhsian

unread,
Mar 9, 1997, 3:00:00 AM3/9/97
to

John H Meyers wrote:

> The only way to do better is to use more digits -- which of course
> anyone can easily do using a variable-precision software package or
> "unlimited-precision" integer arithmetic (perhaps the TI92 has this);
> as far as common calculators go, however, HP is about as good
> as you can possibly get.
>

Question, how could we use ALG48 and it's infinite decimal calculations
to calculate Pi to say 100 decimals? And then how can we use that new Pi
in calculations? From what I know this should be possible by using
strings
as big numbers?

Thanks, and if I have said something somewhat stupid then please tell me
why :)

Harry

Nicholas Bodley

unread,
Mar 9, 1997, 3:00:00 AM3/9/97
to A Suehiro

This matter of other makes giving "nice" ("pretty?"), but
theoretically-incorrect results has me wondering: Is it possible to
"trick" these other makes so that the results they give are
more-obviously wrong? I suspect that it would be possible, by having
operands that have significant digits just "at the edge" of the full
number of digits an HP-48 works with.

I really do wish that the articles by Prof. William Kahan (?) that
appeared some time ago in the H-P Journal (1970s?) were more easily
accessible. He is perhaps unsurpassed anywhere for his deep understanding
of what constitutes an accurate and proper calculation. I believe he was
at Stanford; not sure. He was a consultant to H-P when it developed its
present excellent numerical algorithms. The HP-35 had some inaccuracies
(honestly stated, as I recall!) in its algorithms; later machines fixed
these. I have enormous confidence in the correctness of any numerical
result from any later H-P calculator.


|* Nicholas Bodley *|* Electronic Technician {*} Autodidact & Polymath
|* Waltham, Mass. *|* -----------------------------------------------
|* nbo...@tiac.net *|* When the year 2000 begins, we'll celebrate
|* Amateur musician *|* the 2000th anniversary of the year 1 B.C.E.
--------------------------------------------------------------------------


Philip Karras

unread,
Mar 10, 1997, 3:00:00 AM3/10/97
to

No, the reason HP donesn't get the "right" answer is because it got the
right answer & the TI rounded it's answer to what you think is right.

I remember reading someplace that if you evaluate the expression:
SIN(2*pi) it evaluates as 0, but if you use numbers then it has to
use it's numeric values which are only good to 12 or 13 places & thus
the numeric evaluation is only good to that meny places & HP doesn't
hide this fact from you.

I don't know about you, but I rather like the fact that I can see the
accuracy of the machine instead of having it hide its errors from me,
which a number of other (unmentonable) calculators do. :-)

PK

P.S. someone else will have to help with the method of evaluating
a symbolic expression. It has something to do with flags -2 & -3
being clear & being in RAD mode. But I can't seem to get it to work
so I must be forgetting something.

On Sat, 8 Mar 1997, Dick Smith wrote:

> In message <5frar8$8...@news.infoserve.net> keir wrote:
>
> ] How come when I have my 48 in rads mode, and try to take the SIN of 2
> ] Pi, I get the number 4.135E-13 and not Zero?
>

> Not having an HP48 (yet) this is a bit worrying, as the TI-85 and various
> other Casio-types give zero for this calculation.
>
> Is this why TIs are preferred for education (because they get the answers
> right) whereas HPs are used by engineers who are often quite happy with
> 'near-enough' type answers?
>

Philip Karras

unread,
Mar 10, 1997, 3:00:00 AM3/10/97
to

Oh I got it, it only work for very special cases, SIN(pi) is one.
Clear both -2 & -3 flags then enter <-| pi SIN and you will get 0.

The special cases are: SIN(pi/2), COS(pi), COS(pi/2), TAN(pi), and
SIN(pi).

SIN(2*pi) will NOT reduce to 0 since the calc represents 2 to only
13 places. Tho why it does for pi/2 is beyond me. Prehaps someone
from HP will tell us.

PK

Balazs Fischer

unread,
Mar 10, 1997, 3:00:00 AM3/10/97
to Nicholas Bodley

---===> Quoting Nicholas Bodley to A Suehiro <===---

NB> This matter of other makes giving "nice" ("pretty?"), but
NB> theoretically-incorrect results has me wondering: Is it possible
NB> to "trick" these other makes so that the results they give are
NB> more-obviously wrong?

Try sin(1146408/364913) on a calc that beautifies its results (in rad mode)
and you should get 0. My TI-35 does give the wrong answer while the HP has no
problems. Now you can guess how I came up with this number :-).

cu

Balazs Fischer

Balazs....@studbox.uni-stuttgart.de

... Their sex was so good even the neighbors lit cigarettes!

gmar...@primenet.com

unread,
Mar 10, 1997, 3:00:00 AM3/10/97
to

On Mon, 10 Mar 1997 09:30:25 -0500, Philip Karras
<ke...@access5.digex.net> wrote:

>No, the reason HP donesn't get the "right" answer is because it got the
>right answer & the TI rounded it's answer to what you think is right.

Isn't SIN(2*PI) equal 0? Shouldn't that be that the TI rounded its
answer to what we know to be the correct answer?


Joe Horn

unread,
Mar 10, 1997, 3:00:00 AM3/10/97
to Balazs Fischer

Balazs Fischer wrote:
>
> ---===> Quoting Nicholas Bodley to A Suehiro <===---
>
> NB> This matter of other makes giving "nice" ("pretty?"), but
> NB> theoretically-incorrect results has me wondering: Is it possible
> NB> to "trick" these other makes so that the results they give are
> NB> more-obviously wrong?
>
> Try sin(1146408/364913) on a calc that beautifies its results (in rad mode)
> and you should get 0. My TI-35 does give the wrong answer while the HP has no
> problems.

Unfortunately, the Casio CFX-9800G (the color-display calculator)
gets an answer of -1.6E-12 for this, and the HP48 gets -2.0676E-13.
The real answer is -1.610740019899030939776779...E-12, so I'm afraid
Casio wins this contest hands down.

Sorry. Pick a better example next time.

> Now you can guess how I came up with this number :-).

You obtained the fraction by 'pi' ->NUM ->Q in STD mode.

-Joe-

<META NAME="Joseph K. Horn" CONTENT="mostly baloney">
<mailto:joe...@mail.liberty.com>
<http://www.liberty.com/home/joehorn>
MS Windows: The World's Largest Virus

Eric Gorka

unread,
Mar 11, 1997, 3:00:00 AM3/11/97
to

Yes, but what is 2*PI equal to EXACTLY? Please post it here...
In NUMERICAL, not formula form... I'll check back in a few hundred years.

It is what we ASSUME to be the correct answer, as you could not prove it (I
don't think) because PI is irrational.

If it means THAT much to you, just use one of the lower FIX modes, if the
ACCURACY of the HP is too much for you to handle.

As for the TI, I guess you can't increase the accuracy can you? I wonder
how it knows what PI is EXACTLY? It doesn't.. It basically fudges the
numbers so we get what is assumed.... The HP gets the right answer to what
it knows as PI.

Period.

Eric

A Suehiro

unread,
Mar 11, 1997, 3:00:00 AM3/11/97
to

On Mon, 10 Mar 1997 20:06:53 -0800, Joe Horn
<joe...@mail.liberty.com> wrote:

>Balazs Fischer wrote:
>>
>> ---===> Quoting Nicholas Bodley to A Suehiro <===---
>>
>> NB> This matter of other makes giving "nice" ("pretty?"), but
>> NB> theoretically-incorrect results has me wondering: Is it possible
>> NB> to "trick" these other makes so that the results they give are
>> NB> more-obviously wrong?
>>
>> Try sin(1146408/364913) on a calc that beautifies its results (in rad mode)
>> and you should get 0. My TI-35 does give the wrong answer while the HP has no
>> problems.
>
>Unfortunately, the Casio CFX-9800G (the color-display calculator)
>gets an answer of -1.6E-12 for this, and the HP48 gets -2.0676E-13.
>The real answer is -1.610740019899030939776779...E-12, so I'm afraid
>Casio wins this contest hands down.
>

Outof curiosity, does this answer take into account the 12 significant
digits used by the HP (I have no idea if internally sin is calculated
with double precision numbers) and the probable 14 digit (for 12 digit
display) internal precission of the typical Casio. The Casio's I've
owned seemed to use an extra 2 digits, which were rounded off.

Joeri Van hoyweghen

unread,
Mar 11, 1997, 3:00:00 AM3/11/97
to

Hrair Mekhsian wrote:

>
> John H Meyers wrote:
>
> > The only way to do better is to use more digits -- which of course
> > anyone can easily do using a variable-precision software package or
> > "unlimited-precision" integer arithmetic (perhaps the TI92 has this);
> > as far as common calculators go, however, HP is about as good
> > as you can possibly get.
> >
>
> Question, how could we use ALG48 and it's infinite decimal calculations
> to calculate Pi to say 100 decimals? And then how can we use that new Pi
> in calculations? From what I know this should be possible by using
> strings
> as big numbers?
>
> Thanks, and if I have said something somewhat stupid then please tell me
> why :)
>
> Harry
>


Question, why would you need Pi to 100 decimals ?
For an electronics / nuclear physics engineer 5 to 6
significant digits will do. It's often possible to throw
out floating point numbers altogether and use integers
for scientific programs (an integer multiplication computes
much faster than a floating point one).
The first question you should ask is what precision do I need ?


Joeri.


B.t.w. I assume here you're not working in astrology, but even
there a precision of 24 to 36 digits is sufficient.

Hrair Mekhsian

unread,
Mar 11, 1997, 3:00:00 AM3/11/97
to

Joeri Van hoyweghen wrote:
>
> Hrair Mekhsian wrote:
> >
> > John H Meyers wrote:
> >
> > > The only way to do better is to use more digits -- which of course

> > Question, how could we use ALG48 and it's infinite decimal calculations


> > to calculate Pi to say 100 decimals? And then how can we use that new Pi
> > in calculations? From what I know this should be possible by using
> > strings as big numbers?
>

> Question, why would you need Pi to 100 decimals ?
> For an electronics / nuclear physics engineer 5 to 6
> significant digits will do. It's often possible to throw
> out floating point numbers altogether and use integers
> for scientific programs (an integer multiplication computes
> much faster than a floating point one).
> The first question you should ask is what precision do I need ?
> Joeri.
> B.t.w. I assume here you're not working in astrology, but even
> there a precision of 24 to 36 digits is sufficient.

Ahemm, I think you might have noticed that many things related
to math don't really have much use in everyday life. My question
was math/programming related and does probably like 90% of math
have no interest if not to make you think.

Anyway if you had read the original post you would have noticed
that the 5-6 significant digits were not enough to get the
"theoratically correct answer" of a certain Pi orientated calculation
and that's why I suggested what i suggested...

Harry

BTW: no i don't work in astrology, I am in my last High School Year...

Mika Heiskanen

unread,
Mar 11, 1997, 3:00:00 AM3/11/97
to

In article <3322A8...@hol.gr> Hrair Mekhsian <ha...@hol.gr> writes:

>Question, how could we use ALG48 and it's infinite decimal calculations
>to calculate Pi to say 100 decimals? And then how can we use that new Pi
>in calculations? From what I know this should be possible by using
>strings as big numbers?

The next release of ALG48 will contain an extra library which enables
calculations with string format floating point numbers. The desired
accuracy is specified by the global (or local) variable DIGITS, the
allowed values being 2<=DIGITS<=10000.

Supported operations are + - * / INV NEG SQRT ^ PI EXP LN SINH COSH TANH

--
---
--> Mika Heiskanen mhei...@gamma.hut.fi http://www.hut.fi/~mheiskan

and...@cadence.com

unread,
Mar 11, 1997, 3:00:00 AM3/11/97
to and...@cadence.com

In article <19970308....@risctex.demon.co.uk>,

di...@risctex.demon.co.uk wrote:
>
> In message <5frar8$8...@news.infoserve.net> keir wrote:
>
> ] How come when I have my 48 in rads mode, and try to take the SIN of 2
> ] Pi, I get the number 4.135E-13 and not Zero?
>
> Not having an HP48 (yet) this is a bit worrying, as the TI-85 and various
> other Casio-types give zero for this calculation.
>
> Is this why TIs are preferred for education (because they get the answers
> right) whereas HPs are used by engineers who are often quite happy with
> 'near-enough' type answers?
>
> Dick
>
> --
> =============================================================================
> Dick Smith Acorn Risc PC di...@risctex.demon.co.uk
> =============================================================================

It depends on your definition of "right". Since pi has an infinite
number of digits, the answer can only be zero if all digits are given.
However, I guess you might argue that symbolically it should be able
to calculate it correctly (which is probably why sin of pi gives 0).

Still, if I remember rightly, my Sinclair Cambridge programmable (36
steps!) used to only be accurate to about 3 digits...

0.8 SIN -> .7173560909 (on HP)
-> .717278 (on Sinclair)

I just dug it out to try it ;-)

Andrew

--
*************************************************************
* Andrew Beckett * Tel: +44 1344 360333 *
* Senior Applications Engineer * Fax: +44 1344 360324 *
* Cadence Design Systems Ltd * Email: and...@cadence.com *
* Bagshot Road * *
* Bracknell. RG12 3PH * *
*************************************************************

-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet

gmar...@primenet.com

unread,
Mar 11, 1997, 3:00:00 AM3/11/97
to

On Tue, 11 Mar 1997 13:56:33 +0100, Joeri Van hoyweghen
<JV...@minf.vub.ac.be> wrote:
>
>B.t.w. I assume here you're not working in astrology, but even
>there a precision of 24 to 36 digits is sufficient.

Astrologists need 24 to 36 digits of precision? Oh my, I thought they
were just a bunch of quacks ;-)


Balazs Fischer

unread,
Mar 11, 1997, 3:00:00 AM3/11/97
to Joe Horn

---===> Quoting Joe Horn to Balazs Fischer <===---


> Try sin(1146408/364913) on a calc that beautifies its results (in
> rad mode) and you should get 0. My TI-35 does give the wrong
> answer while the HP has no problems.

JH> Unfortunately, the Casio CFX-9800G (the color-display calculator)

There are calculators with a color display?? What would that be good for
(except for higher quality grobs of Pamela Anderson :-) )?

JH> gets an answer of -1.6E-12 for this, and the HP48 gets -2.0676E-
JH> 13. The real answer is -1.610740019899030939776779...E-12, so I'm
JH> afraid Casio wins this contest hands down.

JH> Sorry. Pick a better example next time.

Seems like the casio has a higher internal precision than the HP. Does it
also get better results with 2*pi, pi/2,... ?

cu

Balazs Fischer

Balazs....@studbox.uni-stuttgart.de

... Its hard to be nostalgic when you can't remember a thing.

Axel Kielhorn

unread,
Mar 12, 1997, 3:00:00 AM3/12/97
to

A Suehiro (asue...@ix.netcom.com) wrote:
: On Sat, 08 Mar 1997 18:09:11 +0100, di...@risctex.demon.co.uk (Dick
: Smith) wrote:

: No,no,no, HPs actually calculate numbers with the _correct_ answer


: given the number of digits of resolution (I actually read something
: about this somewhere, anybody know of it?).

My teacher once said:

When you enter a floating-point number into a computer it is already
wrong. Think of that when you do calculations with floating point.

The same is true for calcs.

--
Axel Kielhorn

Who can calculate sin(2*pi) in his head but has real problems with
sin(2*3.1415926)

John H Meyers

unread,
Mar 13, 1997, 3:00:00 AM3/13/97
to

In article <3322A8...@hol.gr>, Hrair Mekhsian <ha...@hol.gr> writes:

> how could we use ALG48 and its infinite decimal calculations to


> calculate Pi to say 100 decimals? And then how can we use that new Pi
> in calculations?

ALG48 calculates using *integers* of "unlimited" size, rather than
arbitrary *decimals* of precision. Nonetheless, extra bookkeeping
could be used to keep track of an assumed "decimal point" location
in each value; this strategy is in fact used by the Unix "bc" and "dc"
unlimited-precision calculator programs to handle non-integers.

It would take too much space to describe "bc" here, but I copy below
the result it produces for 4*atan(1) while keeping 95 decimal places
during computations, plus the algorithm it uses to compute its a()
function (atan) from its "standard library" (Sun OS 5.3 version).

With the clues that "scale" means the maximum number of decimal digits
to retain during calculations, and that "ibase = A" means nothing
more than to interpret numbers in the familiar base 10, I leave it
to you to see whether you want to try porting this algorithm to ALG48,
or perhaps you'd just like to use the answer, valid to 90+ digits.

Care to figure out how it works? (for Calculus students only)

BTW the "for" loop starts with a=3 and then adds 2 for each extra loop;
the scope of each "while" and "for" is the following { ..... }
(sometimes containing inner nested { .. }, just as in the HP48).

Would you like the rest of the trig/log etc. algorithms from this package?
(You're going to publish the unlimited precision trig/log/exp/hyp library
which you'll make from all this, won't you?)

> From what I know this should be possible by using strings as big numbers?

The Z<->S or ZS function of ALG48 converts between strings of digits
you can read <-> the internal hex strings with which ALG48 computes.

BTW, for a lowly 24-digit precision calculator, see DIGI24 from GD#9(math).

---------- Unix output follows -------------

bc -l
4*a(1)
3.141592653589793238462643383279502884197169399375105820974944592307816\
40628620899862803482534208

/* atan function definition */
define a(x){
auto a, b, c, d, e, f, g, s, t, r, z /* reserve memory for vars */
r = ibase
ibase = A /* interpret numbers in base 10 */
if(x==0) return(0)
if(x==1){
z =.7853981633974483096156608458198757210492923498437764/1
ibase = r
if(scale<52)return(z)
}
t = scale
f=1
while(x > .5){
scale = scale + 1
x= -(1-sqrt(1.+x*x))/x
f=f*2
}
while(x < -.5){
scale = scale + 1
x = -(1-sqrt(1.+x*x))/x
f=f*2
}
s = -x*x
b = f
c = f
d = 1
e = 1
for(a=3;1==1;a=a+2){
b=b*s
c=c*a+d*b
d=d*a
g=c/d
if(g==e){
scale = t
ibase = r
return(x*c/d)
}
e=g

jee...@aol.com

unread,
Mar 13, 1997, 3:00:00 AM3/13/97
to

In article <3322A8...@hol.gr>, Hrair Mekhsian <ha...@hol.gr> writes:

>Question, how could we use ALG48 and it's infinite decimal calculations


>to calculate Pi to say 100 decimals? And then how can we use that new Pi

>in calculations? From what I know this should be possible by using
>strings
>as big numbers?
>


>Thanks, and if I have said something somewhat stupid then please tell me
>why :)
>
>Harry

How about this:
<< 1 + 0 OVER R->B #10d SWAP APOW DUP
#2d ADIV OVER #5d ADIV ROT #8d ADIV
#1d #0d -> A B C N T
<< A B AADD C AADD
DO T SWAP
IF 3 PICK
THEN ASUB
ELSE AADD
END 'T' STO NOT A #4d ADIV DUP 'A' STO
B #25d ADIV DUP 'B' STO C #64d ADIV DUP
'C' STO AADD AADD N #2d + DUP 'N' STO
ADIV DUP Z<->S DUP SIZE 1 DISP
UNTIL "0" ==
END DROP2 T #4d AMUL Z<->S 1 ROT SUB
DUP HEAD "." + SWAP TAIL +
>>
>>

This calculated 100 places of PI (from the decimal point)
in 61.56 secs

Of course, if you use this approximation to PI to try to
calculate SIN(2*PI) then you'll get an answer something like
*.*********(etc) E-101, and it still won't be "zero".

John Edry
JEE...@aol.com

P.S. Can't wait for Mika's next great release of ALG48.

JEEjohn

unread,
Mar 14, 1997, 3:00:00 AM3/14/97
to

Sorry, I forgot to mention how to run the program
to calculate digits of PI.
You enter the number of digits that you want to
calculate, and the program returns a string that
approximates PI to that number of places (after
the decimal point).
While running the program counts down from the
number entered to 0, and displays this in the upper
left corner. The number indicates how many places
that have yet to be calculated.

John Edry
JEE...@aol.com

BTW the program was adapted from a program in
HP 48S/SX Machine Language, Journey to the Center
of the HP 48.

Nacho

unread,
Mar 15, 1997, 3:00:00 AM3/15/97
to

On 11 Mar 1997 18:04:02 -0700, gmar...@primenet.com wrote:

>>B.t.w. I assume here you're not working in astrology, but even
>>there a precision of 24 to 36 digits is sufficient.
>
>Astrologists need 24 to 36 digits of precision? Oh my, I thought they
>were just a bunch of quacks ;-)

Maybe he wanted to say astronomy :)

Bye!


Nacho


/****************************************\
* *
* Email Address: ncc...@arrakis.es *
* *
* PGP Key available. *
* *
\****************************************/

gmar...@primenet.com

unread,
Mar 15, 1997, 3:00:00 AM3/15/97
to

On Mon, 10 Mar 1997 20:06:53 -0800, Joe Horn
<joe...@mail.liberty.com> wrote:

>Balazs Fischer wrote:
>>
>> ---===> Quoting Nicholas Bodley to A Suehiro <===---
>>
>> NB> This matter of other makes giving "nice" ("pretty?"), but
>> NB> theoretically-incorrect results has me wondering: Is it possible
>> NB> to "trick" these other makes so that the results they give are
>> NB> more-obviously wrong?
>>

>> Try sin(1146408/364913) on a calc that beautifies its results (in rad mode)
>> and you should get 0. My TI-35 does give the wrong answer while the HP has no
>> problems.
>

>Unfortunately, the Casio CFX-9800G (the color-display calculator)

>gets an answer of -1.6E-12 for this, and the HP48 gets -2.0676E-13.
>The real answer is -1.610740019899030939776779...E-12, so I'm afraid


>Casio wins this contest hands down.
>

>Sorry. Pick a better example next time.

The TI85 returns -1.6E -12


Robert Tiismus

unread,
Mar 18, 1997, 3:00:00 AM3/18/97
to

I think there are no "right answers" for this problem. It depends how precise
the calculator is. It follows from the next:

sin( Pi + dPi ) = sin( Pi )*cos( dPi ) + cos( Pi )*sin( dPi )

where Pi is the exact value for Pi and dPi is difference between real value
and exact value. Because sin( Pi ) = 0 and cos( Pi ) = -1, we get

sin( Pi + dPi ) = -sin( dPi ) = -dPi because dPi is so small.

so SIN from the nonexact value of Pi gives us the difference between exact Pi
and nonexact Pi which depends on the calculator.
SO: Its wery easy to check which calculator does it better, just pick the value
of Pi from some math book and compare Pi - dPi (which in case of HP48 is some
24 digits number) with the table value...

--
Robert Tiismus | rob...@physic.ut.ee | Undergraduate student in physics
http://www2.physic.ut.ee/~robert/ | in University of Tartu.
| System engineer of computers & nets

Joeri Van hoyweghen

unread,
Mar 18, 1997, 3:00:00 AM3/18/97
to

Yep, sorry for the mistake.

Joeri.

Joe Horn

unread,
Mar 22, 1997, 3:00:00 AM3/22/97
to Robert Tiismus

Robert Tiismus wrote:

> Joe Horn wrote:

> >Balazs Fischer wrote:

> >> Try sin(1146408/364913) on a calc that beautifies its results (in rad mode)
> >> and you should get 0. My TI-35 does give the wrong answer while the HP has no
> >> problems.

> >Unfortunately, the Casio CFX-9800G (the color-display calculator)
> >gets an answer of -1.6E-12 for this, and the HP48 gets -2.0676E-13.
> >The real answer is -1.610740019899030939776779...E-12, so I'm afraid
> >Casio wins this contest hands down.

> I think there are no "right answers" for this problem. It depends how precise
> the calculator is. [snip]

No no no no no!!! There IS a right answer, and it is what it is,
for all eternity, regardless of men or machines. Sin(1146408/364913)
is a NUMBER, a precise point on the real number line. Sure, it's
irrational; yes, any attempt to calculate it in decimal-notation
will be a mere approximation, but PUH-LEEZE do not say that there
exists no "right" answer for it! Sheesh! Ghah! Puh!!!

Pardon my sputtering. Ahem. There; I feel much better now.

Throw sin(1146408/364913) at any decent program that calculates to
a settable number of digits, and you'll see "the real answer" quoted
above (rounded off to 25 significant digits).

If I misunderstood you, please correct me. As a math teacher, I just
go nuts when I hear things like "the right answer depends on the
accuracy of your calculator". Humbug! The accuracy of your calculator
only *hinders* your ability to *recognize* the right answer.

Mika Heiskanen

unread,
Mar 24, 1997, 3:00:00 AM3/24/97
to

Joe Horn <joe...@mail.liberty.com> writes:

>No no no no no!!! There IS a right answer, and it is what it is,
>for all eternity, regardless of men or machines. Sin(1146408/364913)
>is a NUMBER, a precise point on the real number line. Sure, it's
>irrational; yes, any attempt to calculate it in decimal-notation
>will be a mere approximation, but PUH-LEEZE do not say that there
>exists no "right" answer for it! Sheesh! Ghah! Puh!!!
>

>Throw sin(1146408/364913) at any decent program that calculates to
>a settable number of digits, and you'll see "the real answer" quoted
>above (rounded off to 25 significant digits).

However setting a given precision in some program does not necessarily mean
the answer will be returned with that precision. Instead many programs only
approximate the result using basic arithmetic operations using the given or a
slightly higher precision. Depending on the approximation algorithm itself
the results can have far less accuracy than desired.

For example comparing the results from Maple to those with large precision:

1 2 3
Digits:= 123456789012345678901234567890 True accuracy:
------------------------------
25 -.1610740019898616720497115 *10E-11 12
30 -.161074001989903094049711510632 *10E-11 17
40 -.1610740019899030939776779026324*10E-11 28
100 -.1610740019899030939776779026217*10E-11

And with MuPAD:

1 2 3
DIGITS:= 123456789012345678901234567890 True accuracy:
------------------------------
25 -.1610740019899030935883795 e-11 18
30 -.161074001989903093977677902277 e-11 27
40 -.1610740019899030939776779026217e-11 >30
100 -.1610740019899030939776779026217e-11

And with the to be released Long library (with ALG48):

1 2 3
DIGITS:= 123456789012345678901234567890 True accuracy:
------------------------------
25 -.1610740019898616720045105 e-11 12
30 -.161074001989903094049711693996 e-11 17
40 -.1610740019899030939776779026324e-11 28
100 -.1610740019899030939776779026217e-11

The given example of course is a particularly bad example for the common
algorithm of adding consecutive Taylor series terms (with alternating signs)
until the result does not change.

Whenever using these systems one can safely assume that only the basic
arithmetic functions obey the set precision - unless the manual states
otherwise.

Robert Tiismus

unread,
Mar 25, 1997, 3:00:00 AM3/25/97
to

Joe Horn (joe...@mail.liberty.com) wrote:

> Robert Tiismus wrote:
>
>> Joe Horn wrote:
>
>>>Balazs Fischer wrote:
>
>>>> Try sin(1146408/364913) on a calc that beautifies its results (in rad mode)
>>>> and you should get 0. My TI-35 does give the wrong answer while the HP has no
>>>> problems.

>> I think there are no "right answers" for this problem. It depends how precise
>> the calculator is. [snip]
>

> No no no no no!!! There IS a right answer, and it is what it is,
> for all eternity, regardless of men or machines. Sin(1146408/364913)
> is a NUMBER, a precise point on the real number line. Sure, it's

<snip>


> If I misunderstood you, please correct me. As a math teacher, I just

<snip>
Yep you misunrestood me, because I misunerstood Balazs. I was thinking he
wrote about sin(pi) not the sin(fraction). My mistake, didnt' read his message
carefully...
Apologies for the additional stressor caused by me ;)

Robert Tiismus | rob...@physic.ut.ee | Undergraduate student in physics

http://www2.physic.ut.ee/~robert/ | at University of Tartu, Estonia.
| System engineer of computers & nets.

0 new messages