[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: what calculator do you use?



On Mon 13 Jul 2020 at 19:02:38 (-0400), The Wanderer wrote:
> On 2020-07-13 at 08:23, Greg Wooledge wrote:
> > On Mon, Jul 13, 2020 at 06:47:51AM -0400, The Wanderer wrote:
> > 
> >> In some contexts it could even need fewer; for example, calc (as
> >> shipped in Debian) provides the built-in function 'pi()', which
> >> takes a precision - expressed as a value between zero and one - and
> >> returns pi to that level of precision.
> > 
> > I do not understand this description.  How many decimal places do
> > you get for a precision of, say, 0.5?
> 
> (It turns out I got the specification of what the precision can be
> expressed as wrong, and "precision" may not be the correct term for it
> anyway; see below.)
> 
> I don't understand the full algorithm myself, but the output seems
> coherent:
> 
> $ calc
> C-style arbitrary precision calculator (version 2.12.7.2)
> Calc is open software. For license details type:  help copyright
> [Type "exit" to exit, or "help" for help.]
> 
> ; pi(.5)
>         3
> ; pi(.1)
>         3.1
> ; pi(.9)
>         2.7
> ; pi(.05)
>         3.15
> ; pi(.0005)
>         3.1415
> ; pi(.00005)
>         3.1416
> ; pi(.00001)
>         3.14159
> ; pi(.00009)
>         3.1416
> 

It appears to use the argument as an integral factor of the answer
quoted. However, the last example seems wrong. The answer ought to be
3.14163, which is 34907 * 0.00009. Was that a copy/paste failure?

[…]

> Also, it turns out that it accepts values >=1 and <=0 as well:
> 
> ; pi(5)
>         5
> ; pi(10)
>         0
> ; pi(50)
>         0
> ; pi(3)
>         3
> ; pi(4)
>         4
> ; pi(2)
>         4
> ; pi(-1)
>         3
> ; pi(0)
> zero epsilon value for pi
> 
> ; pi(1)
>         3

So it looks like the argument's sign is ignored.

> The results just aren't very useful.

Perhaps it's connected with the facility you mentioned earlier,
the option to present non-integer output in the form of a ratio
of two integers.

Cheers,
David.


Reply to: