Send Programming mailing list submissions to
programming@forums.jsoftware.com
To subscribe or unsubscribe via the World Wide Web, visit
http://jsoftware.com/mailman/listinfo/programming
or, via email, send a message with subject or body 'help' to
programming-requ...@forums.jsoftware.com
General information about the Jsoftware mailing lists is at:
https://code.jsoftware.com/wiki/System/Forums
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Programming digest..."
Today's Topics:
1. Re: newbie question (Jan-Pieter Jacobs)
2. Re: newbie question ('robert therriault' via Programming)
3. Re: newbie question (David Lambert)
4. Re: newbie question (Raul Miller)
5. Rational precision proposal (David Lambert)
6. Re: Rational precision proposal (Raul Miller)
----------------------------------------------------------------------
Message: 1
Date: Sun, 15 May 2022 16:12:42 +0200
From: Jan-Pieter Jacobs <janpieter.jac...@gmail.com>
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] newbie question
Message-ID:
<cans99cbs7nhww6vnhdytgbq_rf2g-izwaks+pwtorrozpyr...@mail.gmail.com>
Content-Type: text/plain; charset="UTF-8"
actually, J lets you approximate pi to as many digits as you'd want, but
you have to know the trick:
pix =. ([: <.@:o. 10^x:)
_10 ]\ ": pix 100
3141592653
5897932384
6264338327
9502884197
1693993751
0582097494
4592307816
4062862089
9862803482
5342117067
9
gives the first 101 digits of pi (including the initial 3). This is so
because it's implemented as special code in J. Somehow, this seems not
yet
to be documented in NuVoc, but can be found e.g. here:
https://code.jsoftware.com/wiki/JPhrases/NumbersCounting
pix gives you an extended integer of pi time 10^y, the _10 ]\ ": just
does
conversion to string, and formatting with 10 digits per line.
Jan-Pieter
On Sun, 15 May 2022, 10:49 Elijah Stone, <elro...@elronnd.net> wrote:
J has a few different ways of representing numbers, including:
- Machine integers (limited to 64 or 32 bit); this is what you get if
you
type a number like 123
- Machine floating-point numbers (limited precision, but can have
decimal
points in them); this is what you get if you type a number like 3.45
or 1p1
- Extended-precision numbers (unlimited precision, but can only
represent
integers and rational numbers); this is what you get if you type a
number
like 123x or 3r4
You would like an unlimited-precision representation of pi, I
assume. But
the
present implementation of j is incapable of this; the only things it can
represent with unlimited precision are integers and rational numbers,
and
pi
is irrational.
Machine representation of irrational numbers is a very interesting
topic,
but
it is fraught with tradeoffs and complexities, and the present
implementation
of j does not attempt it. As far as I know, all implementations of apl
have
the same limitation; there, too, ○1 is a floating-point
approximation. And
I
do not think most apl implementations even have extended-precision
integers or
rational numbers.
You might like to look into computer algebra systems (cas), such as
mathematica.
On Sun, 15 May 2022, yt wrote:
Dear All,
i come back to start in J
in jijx>tour>overview
3p5 NB. Pi (3 * Pi ^ 5)
918.059
may be it is not the better way to find Pi :
1p1 NB. Pi (1 * Pi ^ 1)
1p1
3.14159
1p1x
|ill-formed number
| 1p1x
| ^
but this is ok for :
^/ 2 3 4
2.41785e24
^/ 2 3 4x
2417851639229258349412352
3^4
81
2^81
2.41785e24
2^81x
2417851639229258349412352
why 1p1 is not good ?
i have not this problem in APL
Sorry for the inconvenience
Regards,
Yves
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
------------------------------
Message: 2
Date: Sun, 15 May 2022 08:57:03 -0700
From: "'robert therriault' via Programming"
<programm...@jsoftware.com>
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] newbie question
Message-ID: <6dd3a035-288d-478d-bf12-1167c801d...@mac.com>
Content-Type: text/plain; charset=utf-8
I actually made a video for Pi day showing this technique and the
various adjustments you need to make to get pi in an extended form
from its original float representation.
https://youtu.be/vyILnD0e2IE
Cheers, bob
On May 15, 2022, at 07:12, Jan-Pieter Jacobs
<janpieter.jac...@gmail.com> wrote:
actually, J lets you approximate pi to as many digits as you'd want, but
you have to know the trick:
pix =. ([: <.@:o. 10^x:)
_10 ]\ ": pix 100
3141592653
5897932384
6264338327
9502884197
1693993751
0582097494
4592307816
4062862089
9862803482
5342117067
9
gives the first 101 digits of pi (including the initial 3). This is so
because it's implemented as special code in J. Somehow, this seems
not yet
to be documented in NuVoc, but can be found e.g. here:
https://code.jsoftware.com/wiki/JPhrases/NumbersCounting
pix gives you an extended integer of pi time 10^y, the _10 ]\ ": just
does
conversion to string, and formatting with 10 digits per line.
Jan-Pieter
On Sun, 15 May 2022, 10:49 Elijah Stone, <elro...@elronnd.net> wrote:
J has a few different ways of representing numbers, including:
- Machine integers (limited to 64 or 32 bit); this is what you get
if you
type a number like 123
- Machine floating-point numbers (limited precision, but can have
decimal
points in them); this is what you get if you type a number like 3.45
or 1p1
- Extended-precision numbers (unlimited precision, but can only
represent
integers and rational numbers); this is what you get if you type a
number
like 123x or 3r4
You would like an unlimited-precision representation of pi, I
assume. But
the
present implementation of j is incapable of this; the only things it
can
represent with unlimited precision are integers and rational
numbers, and
pi
is irrational.
Machine representation of irrational numbers is a very interesting
topic,
but
it is fraught with tradeoffs and complexities, and the present
implementation
of j does not attempt it. As far as I know, all implementations of apl
have
the same limitation; there, too, ○1 is a floating-point
approximation. And
I
do not think most apl implementations even have extended-precision
integers or
rational numbers.
You might like to look into computer algebra systems (cas), such as
mathematica.
On Sun, 15 May 2022, yt wrote:
Dear All,
i come back to start in J
in jijx>tour>overview
3p5 NB. Pi (3 * Pi ^ 5)
918.059
may be it is not the better way to find Pi :
1p1 NB. Pi (1 * Pi ^ 1)
1p1
3.14159
1p1x
|ill-formed number
| 1p1x
| ^
but this is ok for :
^/ 2 3 4
2.41785e24
^/ 2 3 4x
2417851639229258349412352
3^4
81
2^81
2.41785e24
2^81x
2417851639229258349412352
why 1p1 is not good ?
i have not this problem in APL
Sorry for the inconvenience
Regards,
Yves
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
------------------------------
Message: 3
Date: Sun, 15 May 2022 13:37:21 -0400
From: David Lambert <b49p23t...@gmail.com>
To: programming <programm...@jsoftware.com>
Subject: Re: [Jprogramming] newbie question
Message-ID: <b0cf4a4f-f77a-2d13-c5be-bdcdf4757...@gmail.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
A global setting determines default floating print precision. Format
accepts customization. Rationals print to arbitrary base 10
representation.
9!:10'' NB. show print precision
6
1p1
3.14159
9!:11 ] 16 NB. set default
1x1
2.718281828459045
NB. customize
":!.3 ] 2p1 NB. tauday.com
6.28
NB. compute 32 digits of Euler's number
50j48 ": ([: +/ %@:!)@i. 2 1 1 $ 30 35x
2.718281828459045235360287471352658602238073315078
2.718281828459045235360287471352662497757147554933
NB. ^xxxxxxxxxxxxxxxx
NB. view in fixed width please.
https://www.jsoftware.com/help/dictionary/dx009.htm
Date: Sun, 15 May 2022 10:28:30 +0200
From: yt<yves.tan...@frmail.net>
To:programm...@jsoftware.com
Subject: Re: [Jprogramming] newbie question
Message-ID:<eee70943-3619-d8c6-fa5c-d71dc8d5f...@frmail.net>
Content-Type: text/plain; charset=UTF-8; format=flowed
Dear All,
i come back to start in J
in jijx>tour>overview
3p5 NB. Pi (3 * Pi ^ 5)
918.059
may be it is not the better way to find Pi :
1p1 NB. Pi (1 * Pi ^ 1)
1p1
3.14159
------------------------------
Message: 4
Date: Sun, 15 May 2022 14:36:20 -0400
From: Raul Miller <rauldmil...@gmail.com>
To: Programming forum <programm...@jsoftware.com>
Subject: Re: [Jprogramming] newbie question
Message-ID:
<CAD2jOU_smBM-+=K8mqepJc2FeE76B4J=L=6bxsngnxzmcat...@mail.gmail.com>
Content-Type: text/plain; charset="UTF-8"
I would have used 50j48 ": ([: +/ %@:!)@i. 2 1 1 $ 30 40x except that
we want pi, instead of e.
For pi:
50j48":<.@o.&.(*&(10x^48))1
3.141592653589793238462643383279502884197169399375
Thanks,