• fixed point arithmetic, demo of higher order convergence

    From none) (albert@21:1/5 to All on Sun Sep 3 11:10:00 2023
    So I decided to add a one screen fixed point facility to ciforth,
    waiting for ages in the projecteuler directory.
    I invented a high order process to calculate pi, an opportunity
    to demonstrates what you can do with fixed point. ----------------------------------------8< -------------
    ( *s /s fix-scale -fixedpoint- )
    WANT ALIAS
    8 CELLS 4 - CONSTANT fix-scale \ n represents n.2^-scale.
    1 fix-scale LSHIFT CONSTANT 1/1
    1 fix-scale 1- LSHIFT CONSTANT 1/2
    \ As */ * / but scaled.
    : */s >R M* R> FM/MOD NIP ;
    : *s 1/1 */s ; : /s 1/1 SWAP */s ;
    \ Most other operators remain the same:
    '+ ALIAS +s '- ALIAS -s '*/ ALIAS */s
    \ For a RATIO (n/d) return an equivalent scaled NUMBER.
    '/s ALIAS rat>s \ By accident.
    \ Print a scaled double number with n digits.
    : D.s >R 1/1 FM/MOD 0 <# #S #> TYPE &. EMIT
    R> 0 DO BASE @ 1/1 */MOD &0 + EMIT LOOP DROP SPACE ;
    : U.s 0 SWAP D.s ;
    ----------------------------------------8< -------------
    Actual and tested code. You must add a blank to each ' and define
    constants for &. and &0 for it to be ISO.
    fix-scale is such that the range is (-8,+8) , but can be changed.

    The idea is that cos(pi/2) should be zero.
    cos() is calculated by a power series:
    1.x^1/1 - 3.x^3/3! + 5.x^5/5! ...
    "
    AMDX86 ciforth 5.4.0

    ciforth lab $Revision: 5.171 $ (c) Albert van der Horst
    ...
    S[ 1 ] OK INCLUDE calcpi.frt
    */s : ISN'T UNIQUE

    S[ ] OK 1 DEBUG ! \ Showing terms in calculating cos

    S[ ] OK 3 2 rat>s \ calculate cos pi for 1.5

    S[ 1729382256910270464 ] OK cos
    1 1.12500000000000000000
    3 0.21093750000000000000
    5 0.01582031249999999843
    7 0.00063563755580356949
    9 0.00001589093889508771
    11 0.00000027086827661827
    13 0.00000000334864627606
    15 0.00000000003139355702
    17 0.00000000000023083444
    19 0.00000000000000136609
    21 0.00000000000000000520

    S[ 81554440978406003 ] OK s.
    0.07073720166770290900 \ Is nearly a zero.
    S[ ] OK 0 debug !

    S[ ] OK \ for third order convergence the precision triples

    S[ ] OK third-order
    \ the cos is the correction
    0.07073720166770290900
    0.00005912512715926503
    0.00000000000003444466
    0.00000000000000000086
    0.00000000000000000000
    pi=~3.14159265358979323916

    S[ ] OK \ for fifth order convergence the zeroes multiply by 5.

    S[ ] OK fifth-order
    \ cos correction
    0.07073720166770290900 0.07079619356654995136
    0.00000013322834667081 0.00000013322834667081
    -0.00000000000000000346 -0.00000000000000000346
    0.00000000000000000086 0.00000000000000000086
    0.00000000000000000000 0.00000000000000000000
    pi=~3.14159265358979323916

    916 864 - .
    52 OK

    S[ ] OK \ The precision and steps are actually the same for both.
    "

    The actual code follows.
    We take advantage that:
    1. the derivative is known to be a sine : dx -dx^3/6
    2. second order and fourth order terms are missing.

    =========================================================
    \ For reference
    \ 3.1415926535 8979323846 2643383279
    INCLUDE fix.blk
    VARIABLE DEBUG 0 DEBUG !
    : s. DUP 0< IF &- EMIT THEN ABS 20 U.s ;
    \ For x calculate the cosine .
    VARIABLE x^2
    VARIABLE sum

    : cos DUP *s x^2 !
    1/1 sum !
    1/1 1000 1 DO
    I / I 1+ / x^2 @ *s
    sum @ I 1- 4 MOD IF OVER + ELSE OVER - THEN sum !
    DUP 0= IF DROP LEAVE THEN
    DEBUG @ IF I . DUP s. CR THEN
    2 +LOOP sum @ ;

    \ Third-order order convergence.
    : third-order
    3 2 rat>s DUP cos DUP s. CR
    + DUP cos DUP s. CR
    + DUP cos DUP s. CR
    + DUP cos DUP s. CR
    + DUP cos DUP s. CR
    DROP 2 * "pi=~" TYPE s. CR
    ;

    \ For x return x+3.x^3
    : correction DUP DUP DUP *s *s 6 / + ;

    \ Fifth order convergence.
    : fifth-order
    3 2 rat>s DUP cos DUP s. correction DUP s. CR
    + DUP cos DUP s. correction DUP s. CR
    + DUP cos DUP s. correction DUP s. CR
    + DUP cos DUP s. correction DUP s. CR
    + DUP cos DUP s. correction DUP s. CR
    DROP 2 * "pi=~" TYPE s. CR
    ;
    ==============================================================

    For the smart people:
    - why is there a plus not a minus in the fifth order correction?
    - make a double precision version where the effect is more
    visible.

    Enjoy

    Groetjes Albert
    --
    Don't praise the day before the evening. One swallow doesn't make spring.
    You must not say "hey" before you have crossed the bridge. Don't sell the
    hide of the bear until you shot it. Better one bird in the hand than ten in
    the air. First gain is a cat spinning. - the Wise from Antrim -

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Marcel Hendrix@21:1/5 to none albert on Sun Sep 3 03:36:09 2023
    On Sunday, September 3, 2023 at 11:10:04 AM UTC+2, none albert wrote:
    So I decided to add a one screen fixed point facility to ciforth,
    waiting for ages in the projecteuler directory.
    I invented a high order process to calculate pi, an opportunity
    to demonstrates what you can do with fixed point.

    :--)

    With a little help of our friends (Wil Baden, mpfr authors), you
    could have done:

    NEEDS -xopg

    .ARBITRARY.P ( default 4096 byte variables )

    0-VALUE GVAL a 0-VALUE GVAL b 0-VALUE GVAL c
    0-VALUE GVAL disc

    : quadraticroot ( F: a b c -- y1 y2 )
    TO c TO b TO a
    LET disc=SQRT(b*b-4*a*c):
    LET ((-b+disc)/(2*a),(-b-disc)/(2*a)):
    ;

    FORTH> CR LET. MAX(quadraticroot(1,-1,-1)): ( golden ratio)
    1.6180339887498948482045868343656381177203 ok
    ( OEIS: 1, 6, 1, 8, 0, 3, 3, 9, 8, 8, 7, 4, 9, 8, 9, 4, 8, 4, 8, 2, 0, 4, 5, 8, 6,
    8, 3, 4, 3, 6, 5, 6, 3, 8, 1, 1, 7, 7, 2, 0, 3, ^^ 0, 9, 1, 7, 9, 8, 0, 5, 7, 6, 2, 8,
    6, 2, 1, 3, 5, 4, 4, 8, 6, 2, 2, 7, 0, 5, 2, 6, 0, 4, 6, 2, 8, 1, 8, 9, 0, 2, 4, 4,
    9, 7, 0, 7, 2, 0, 7, 2, 0, 4, 1, 8, 9, 3, 9, 1, 1, 3, 7, 4, 8, 4, 7, 5
    Wolfram: can't be copied because of HTML tricks )

    I'm currently using xopg in my iSPICE simulator. One day, there
    may be an arbitrary-precision SPICE, but for now speed is
    more interesting.

    -marcel

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From minforth@21:1/5 to Marcel Hendrix on Sun Sep 3 06:00:37 2023
    Marcel Hendrix schrieb am Sonntag, 3. September 2023 um 12:36:11 UTC+2:
    On Sunday, September 3, 2023 at 11:10:04 AM UTC+2, none albert wrote:
    So I decided to add a one screen fixed point facility to ciforth,
    waiting for ages in the projecteuler directory.
    I invented a high order process to calculate pi, an opportunity
    to demonstrates what you can do with fixed point.
    :--)

    \ Calculation of digits of pi without floating-point
    \ The algorithm calculate one digit at the time
    \ Michel Jean, April 2020

    1001 constant nbr-digits \ number of digit - add one, the last digit is not printed
    variable pos \ position in the array
    variable ret \ carry (retenue in french ;-) ) nbr-digits 10 * 3 / constant nbr-cells \ initialisation on the number of cells variable arr-cells nbr-cells cells allot

    : initialisation ( -- ) \ initialisation of the array
    nbr-cells 0 do
    2 arr-cells i cells + !
    loop ;

    : algo-base ( -- )
    pos @ 1 = if
    1 cells arr-cells + @ 10 * ret @ +
    dup
    10 mod arr-cells 1 cells + !
    10 / ret !
    else
    pos @ cells arr-cells + @ 10 * ret @ +
    2 pos @ * 1 -
    2dup
    mod arr-cells pos @ cells + !
    / pos @ 1 - * ret !
    then ;

    : release-stack \ hold the last digit and release other digits of the stack
    depth 1 > if depth 1- roll . recurse else then ;

    : release-stack+1 \ hold the last digit and release other digits of the stack + 1 modulo 10
    depth 1 > if
    depth 1- roll 1+ 10 mod .
    recurse else then ;

    : set-predigit ( -- n )
    ret @ dup 9 < if release-stack else
    dup 10 = if release-stack+1 drop 0 else
    then then ;

    : 1digit ( -- ) \ calculate 1 digit at the time
    1 nbr-cells do
    i pos ! algo-base -1 +loop set-predigit ;

    : run ( -- )
    0 ret ! initialisation
    nbr-digits 50 / 0 do
    50 0 do 1digit loop \ 50 digits by line
    cr loop
    drop ; \ drop the last digit (value not safe)

    cr run

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From dxforth@21:1/5 to minforth on Sun Sep 3 23:57:02 2023
    On 3/09/2023 11:00 pm, minforth wrote:
    Marcel Hendrix schrieb am Sonntag, 3. September 2023 um 12:36:11 UTC+2:
    On Sunday, September 3, 2023 at 11:10:04 AM UTC+2, none albert wrote:
    So I decided to add a one screen fixed point facility to ciforth,
    waiting for ages in the projecteuler directory.
    I invented a high order process to calculate pi, an opportunity
    to demonstrates what you can do with fixed point.
    :--)

    \ Calculation of digits of pi without floating-point
    \ The algorithm calculate one digit at the time
    \ Michel Jean, April 2020

    Fails after 263 digits on a 16-bit forth. Single precision math only
    takes one so far.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From none) (albert@21:1/5 to mhx@iae.nl on Sun Sep 3 21:31:42 2023
    In article <2265ddd9-d878-4644-a122-38c8447304f7n@googlegroups.com>,
    Marcel Hendrix <mhx@iae.nl> wrote:
    On Sunday, September 3, 2023 at 11:10:04 AM UTC+2, none albert wrote:
    So I decided to add a one screen fixed point facility to ciforth,
    waiting for ages in the projecteuler directory.
    I invented a high order process to calculate pi, an opportunity
    to demonstrates what you can do with fixed point.

    :--)

    With a little help of our friends (Wil Baden, mpfr authors), you
    could have done:

    NEEDS -xopg

    .ARBITRARY.P ( default 4096 byte variables )

    0-VALUE GVAL a 0-VALUE GVAL b 0-VALUE GVAL c
    0-VALUE GVAL disc

    : quadraticroot ( F: a b c -- y1 y2 )
    TO c TO b TO a
    LET disc=SQRT(b*b-4*a*c):
    LET ((-b+disc)/(2*a),(-b-disc)/(2*a)):
    ;

    FORTH> CR LET. MAX(quadraticroot(1,-1,-1)): ( golden ratio)
    1.6180339887498948482045868343656381177203 ok
    ( OEIS: 1, 6, 1, 8, 0, 3, 3, 9, 8, 8, 7, 4, 9, 8, 9, 4, 8, 4, 8, 2, 0, 4, 5, 8, 6,
    8, 3, 4, 3, 6, 5, 6, 3, 8, 1, 1, 7, 7, 2, 0, 3, ^^ 0, 9, 1, 7, 9, 8, 0, 5, 7, 6, 2, 8,
    6, 2, 1, 3, 5, 4, 4, 8, 6, 2, 2, 7, 0, 5, 2, 6, 0, 4, 6, 2, 8, 1, 8, 9, 0, 2, 4, 4,
    9, 7, 0, 7, 2, 0, 7, 2, 0, 4, 1, 8, 9, 3, 9, 1, 1, 3, 7, 4, 8, 4, 7, 5 >Wolfram: can't be copied because of HTML tricks )

    I'm currently using xopg in my iSPICE simulator. One day, there
    may be an arbitrary-precision SPICE, but for now speed is
    more interesting.

    Thank you for drawing attention that I can do nice things with a
    one screen facility, while others need big packages. ;-)


    -marcel
    --
    Don't praise the day before the evening. One swallow doesn't make spring.
    You must not say "hey" before you have crossed the bridge. Don't sell the
    hide of the bear until you shot it. Better one bird in the hand than ten in
    the air. First gain is a cat spinning. - the Wise from Antrim -

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Brian Fox@21:1/5 to none albert on Sun Sep 3 20:49:22 2023
    On Sunday, September 3, 2023 at 3:31:49 PM UTC-4, none albert wrote:

    Thank you for drawing attention that I can do nice things with a
    one screen facility, while others need big packages. ;-)


    I am seeing a t-shirt or a bumper sticker that says:

    "Forth programmers do it with smaller packages"

    :-)))))))))))

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From none) (albert@21:1/5 to mhx@iae.nl on Mon Sep 4 11:30:25 2023
    In article <2265ddd9-d878-4644-a122-38c8447304f7n@googlegroups.com>,
    Marcel Hendrix <mhx@iae.nl> wrote:
    On Sunday, September 3, 2023 at 11:10:04 AM UTC+2, none albert wrote:
    So I decided to add a one screen fixed point facility to ciforth,
    waiting for ages in the projecteuler directory.
    I invented a high order process to calculate pi, an opportunity
    to demonstrates what you can do with fixed point.

    :--)

    With a little help of our friends (Wil Baden, mpfr authors), you
    could have done:

    NEEDS -xopg

    .ARBITRARY.P ( default 4096 byte variables )

    0-VALUE GVAL a 0-VALUE GVAL b 0-VALUE GVAL c
    0-VALUE GVAL disc

    : quadraticroot ( F: a b c -- y1 y2 )
    TO c TO b TO a
    LET disc=SQRT(b*b-4*a*c):
    LET ((-b+disc)/(2*a),(-b-disc)/(2*a)):
    ;

    FORTH> CR LET. MAX(quadraticroot(1,-1,-1)): ( golden ratio)
    1.6180339887498948482045868343656381177203 ok
    <SNIP>
    Challenge accepted.
    Adding a square root on top of the one screen: --------------------8<----------------------------------

    INCLUDE fix.blk
    : s. DUP 0< IF &- EMIT THEN ABS 20 U.s ;

    \ For DOUBLE return FLOOR of its square root
    \ If the double is interpreted as a scaled number, so must floor.
    : DSQRT 2DUP OR 0= IF DROP EXIT THEN
    DUP IF MAX-INT ELSE 1000 THEN >R
    BEGIN 2DUP R@ SM/REM R@ + 1 RSHIFT DUP R@ < WHILE RDROP >R DROP REPEAT
    2DROP 2DROP R> ;

    : SQRTs 1/1 M* DSQRT ;

    : golden-ratio 5 1 rat>s SQRTs 1/1 +s 1/1 2 * /s s. ;

    golden-ratio
    \ 1.61803398874989484788 --------------------8<----------------------------------


    -marcel

    Groetjes Albert
    --
    Don't praise the day before the evening. One swallow doesn't make spring.
    You must not say "hey" before you have crossed the bridge. Don't sell the
    hide of the bear until you shot it. Better one bird in the hand than ten in
    the air. First gain is a cat spinning. - the Wise from Antrim -

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From none) (albert@21:1/5 to dxforth@gmail.com on Mon Sep 4 11:25:39 2023
    In article <ud23be$u4ff$1@dont-email.me>, dxforth <dxforth@gmail.com> wrote: >On 3/09/2023 11:00 pm, minforth wrote:
    Marcel Hendrix schrieb am Sonntag, 3. September 2023 um 12:36:11 UTC+2:
    On Sunday, September 3, 2023 at 11:10:04 AM UTC+2, none albert wrote: >>>> So I decided to add a one screen fixed point facility to ciforth,
    waiting for ages in the projecteuler directory.
    I invented a high order process to calculate pi, an opportunity
    to demonstrates what you can do with fixed point.
    :--)

    \ Calculation of digits of pi without floating-point
    \ The algorithm calculate one digit at the time
    \ Michel Jean, April 2020

    Fails after 263 digits on a 16-bit forth. Single precision math only
    takes one so far.

    Happily chugging along with 10,000 digits in my 64 bits Forth,
    in one minute 17 seconds.
    The lines contain 50 digits, on average only.

    Groetjes Albert
    --
    Don't praise the day before the evening. One swallow doesn't make spring.
    You must not say "hey" before you have crossed the bridge. Don't sell the
    hide of the bear until you shot it. Better one bird in the hand than ten in
    the air. First gain is a cat spinning. - the Wise from Antrim -

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Marcel Hendrix@21:1/5 to none albert on Mon Sep 4 10:13:57 2023
    On Monday, September 4, 2023 at 11:30:29 AM UTC+2, none albert wrote:
    In article <2265ddd9-d878-4644...@googlegroups.com>,
    Marcel Hendrix <m...@iae.nl> wrote:
    [..]
    Challenge accepted.
    Adding a square root on top of the one screen:
    [..]
    : golden-ratio 5 1 rat>s SQRTs 1/1 +s 1/1 2 * /s s. ;

    golden-ratio
    \ 1.61803398874989484788

    Are the last 4 digits accurate?

    avh: 1.61803398874989484788
    mpc: 1.6180339887498948482045868343656381177203

    -marcel

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Marcel Hendrix@21:1/5 to none albert on Mon Sep 4 10:14:04 2023
    On Monday, September 4, 2023 at 11:25:46 AM UTC+2, none albert wrote:
    [..]
    Happily chugging along with 10,000 digits in my 64 bits Forth,
    in one minute 17 seconds.
    The lines contain 50 digits, on average only.

    Here it needs 2.23 seconds (I/O time about 200ms).

    FORTH> RUN
    3141592653589793238462643383279502884197169399375 10582097494459230781640628620899862803482534211706 79821480865132823066470938446095505822317253594081 2848111745028410270193852110555964462294895493038 19644288109756659334461284756482337867831652712019 091456485669234603486104543266482133936072602491412 73724587006606315588174881520920962829254091715364 3678925903600113305305488204665213841469519415116 094330572703657595919530921861173819326117931051185 48074462379962749567351885752724891227938183011949 1298336733624406566430860213949463952247371907021 798609437027705392171762931767523846748184676694051 32000568127145263560827785771342757789609173637178 72146844090122495343014654958537105079227968925892 35420199561121290219608640344181598136297747713099 60518707211349999998372978049951059731732816096318 59502445945534690830264252230825334468503526193118 81710100031378387528865875332083814206171776691473 03598253490428755468731159562863882353787593751957 78185778053217122680661300192787661119590921642019 89380952572010654858632788659361533818279682303019 52035301852968995773622599413891249721775283479131 51557485724245415069595082953311686172785588907509 83817546374649393192550604009277016711390098488240 12858361603563707660104710181942955596198946767837 44944825537977472684710404753464620804668425906949 12933136770289891521047521620569660240580381501935 11253382430035587640247496473263914199272604269922 79678235478163600934172164121992458631503028618297 45557067498385054945885869269956909272107975093029 55321165344987202755960236480665499119881834797753 56636980742654252786255181841757467289097777279380 00816470600161452491921732172147723501414419735685 48161361157352552133475741849468438523323907394143 33454776241686251898356948556209921922218427255025 42568876717904946016534668049886272327917860857843 83827967976681454100953883786360950680064225125205 11739298489608412848862694560424196528502221066118 63067442786220391949450471237137869609563643719172 87467764657573962413890865832645995813390478027590 09946576407895126946839835259570982582262052248940 77267194782684826014769909026401363944374553050682 03496252451749399651431429809190659250937221696461 51570985838741059788595977297549893016175392846813 82686838689427741559918559252459539594310499725246 80845987273644695848653836736222626099124608051243 8843904512441365497627807977156914359977001296160 894416948685558484063534220722258284886481584560285 0601684273945226746767889525213852254995466672782 398645659611635488623057745649803559363456817432411 25150760694794510965960940252288797108931456691368 67228748940560101503308617928680920874760917824938 58900971490967598526136554978189312978482168299894 87226588048575640142704775551323796414515237462343 64542858444795265867821051141354735739523113427166 10213596953623144295248493718711014576540359027993 44037420073105785390621983874478084784896833214457 13868751943506430218453191048481005370614680674919 2781911979399520614196634287544406437451237181921 799983910159195618146751426912397489409071864942319 6156794520809514655022523160388193014209376213785 595663893778708303906979207734672218256259966150142 15030680384477345492026054146659252014974428507325 18666002132434088190710486331734649651453905796268 56100550810665879699816357473638405257145910289706 41401109712062804390397595156771577004203378699360 07230558763176359421873125147120532928191826186125 86732157919841484882916447060957527069572209175671 1672291098169091528017350671274858322287183520935 396572512108357915136988209144421006751033467110314 12671113699086585163983150197016515116851714376576 18351556508849099898599823873455283316355076479185 35893226185489632132933089857064204675259070915481 41654985946163718027098199430992448895757128289059 23233260972997120844335732654893823911932597463667 30583604142813883032038249037589852437441702913276 56180937734440307074692112019130203303801976211011 00449293215160842444859637669838952286847831235526 58213144957685726243344189303968642624341077322697 8028073189154411010446823252716201052652272111660 396665573092547110557853763466820653109896526918620 56476931257058635662018558100729360659876486117910 45334885034611365768675324944166803962657978771855 60845529654126654085306143444318586769751456614068 00700237877659134401712749470420562230538994561314 07112700040785473326993908145466464588079727082668 30634328587856983052358089330657574067954571637752 54202114955761581400250126228594130216471550979259 23099079654737612551765675135751782966645477917450 11299614890304639947132962107340437518957359614589 0193897131117904297828564750320319869151402870808 599048010941214722131794764777262241425485454033215 71853061422881375850430633217518297986622371721591 60771669254748738986654949450114654062843366393790 03976926567214638530673609657120918076383271664162 7488880078692560290228472104031721186082041900042 296617119637792133757511495950156604963186294726547 36425230817703675159067350235072835405670403867435 13622224771589150495309844489333096340878076932599 39780541934144737744184263129860809988868741326047 21569516239658645730216315981931951673538129741677 29478672422924654366800980676928238280689964004824 35403701416314965897940924323789690706977942236250 82216889573837986230015937764716512289357860158816 17557829735233446042815126272037343146531977774160 31990665541876397929334419521541341899485444734567 38316249934191318148092777710386387734317720754565 45322077709212019051660962804909263601975988281613 32316663652861932668633606273567630354477628035045 07772355471058595487027908143562401451718062464362 67945612753181340783303362542327839449753824372058 35311477119926063813346776879695970309833913077109 87040859133746414428227726346594704745878477872019 27715280731767907707157213444730605700733492436931 13835049316312840425121925651798069411352801314701 30478164378851852909285452011658393419656213491434 15956258658655705526904965209858033850722426482939 72858478316305777756068887644624824685792603953527 73480304802900587607582510474709164396136267604492 56274204208320856611906254543372131535958450687724 60290161876679524061634252257719542916299193064553 77991403734043287526288896399587947572917464263574 55254079091451357111369410911939325191076020825202 61879853188770584297259167781314969900901921169717 37278476847268608490033770242429165130050051683233 64350389517029893922334517220138128069650117844087 45196012122859937162313017114448464090389064495444 00619869075485160263275052983491874078668088183385 10228334508504860825039302133219715518430635455007 66828294930413776552793975175461395398468339363830 47461199665385815384205685338621867252334028308711 23282789212507712629463229563989898935821167456270 10218356462201349671518819097303811980049734072396 10368540664319395097901906996395524530054505806855 01956730229219139339185680344903982059551002263535 36192041994745538593810234395544959778377902374216 17271117236434354394782218185286240851400666044332 5888569867054315470696574745855033232334210730154 594051655379068662733379958511562578432298827372319 89875714159578111963583300594087306812160287649628 67446047746491599505497374256269010490377819868359 38146574126804925648798556145372347867330390468838 34363465537949864192705638729317487233208376011230 29911367938627089438799362016295154133714248928307 22012690147546684765357616477379467520049075715552 78196536213239264061601363581559074220202031872776 05277219005561484255518792530343513984425322341576 23361064250639049750086562710953591946589751413103 48227693062474353632569160781547818115284366795706 11086153315044521274739245449454236828860613408414 86377670096120715124914043027253860764823634143346 23518975766452164137679690314950191085759844239198 62916421939949072362346468441173940326591840443780 51333894525742399508296591228508555821572503107125 70126683024029295252201187267675622041542051618416 34847565169998116141010029960783869092916030288400 26910414079288621507842451670908700069928212066041 83718065355672525325675328612910424877618258297651 57959847035622262934860034158722980534989650226291 74878820273420922224533985626476691490556284250391 27577102840279980663658254889264880254566101729670 26640765590429099456815065265305371829412703369313 78517860904070866711496558343434769338578171138645 5873678123014587687126603489139095620099393610310 291616152881384379099042317473363948045759314931405 29763475748119356709110137751721008031559024853090 66920376719220332290943346768514221447737939375170 34436619910403375111735471918550464490263655128162 28824462575916333039107225383742182140883508657391 77150968288747826569959957449066175834413752239709 68340800535598491754173818839994469748676265516582 7658483588453142775687900290951702835297163445621 296404352311760066510124120065975585127617858382920 41974844236080071930457618932349229279650198751872 12726750798125547095890455635792122103334669749923 56302549478024901141952123828153091140790738602515 22742995818072471625916685451333123948049470791191 53267343028244186041426363954800044800267049624820 17928964766975831832713142517029692348896276684403 23260927524960357996469256504936818360900323809293 45958897069536534940603402166544375589004563288225 05452556405644824651518754711962184439658253375438 8569094113031509526179378002974120766514793942590 298969594699556576121865619673378623625612521632086 28692221032748892186543648022967807057656151446320 46927906821207388377814233562823608963208068222468 01224826117718589638140918390367367222088832151375 56003727983940041529700287830766709444745601345564 17254370906979396122571429894671543578468788614445 81231459357198492252847160504922124247014121478057 34551050080190869960330276347870810817545011930714 12233908663938339529425786905076431006383519834389 34159613185434754649556978103829309716465143840700 70736041123735998434522516105070270562352660127648 48308407611830130527932054274628654036036745328651 05706587488225698157936789766974220575059683440869 73502014102067235850200724522563265134105592401902 74216248439140359989535394590944070469120914093870 01264560016237428802109276457931065792295524988727 58461012648369998922569596881592056001016552563756
    2.489 seconds elapsed. ok

    No idea if it's correct :--)

    -marcel

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From minforth@21:1/5 to Marcel Hendrix on Mon Sep 4 11:28:37 2023
    Marcel Hendrix schrieb am Montag, 4. September 2023 um 19:14:06 UTC+2:
    On Monday, September 4, 2023 at 11:25:46 AM UTC+2, none albert wrote:
    [..]
    Happily chugging along with 10,000 digits in my 64 bits Forth,
    in one minute 17 seconds.
    The lines contain 50 digits, on average only.
    Here it needs 2.23 seconds (I/O time about 200ms).

    FORTH> RUN
    3141592653589793238462643383279502884197169399375 10582097494459230781640628620899862803482534211706 79821480865132823066470938446095505822317253594081 2848111745028410270193852110555964462294895493038 19644288109756659334461284756482337867831652712019 091456485669234603486104543266482133936072602491412 73724587006606315588174881520920962829254091715364 3678925903600113305305488204665213841469519415116 094330572703657595919530921861173819326117931051185 48074462379962749567351885752724891227938183011949 1298336733624406566430860213949463952247371907021 798609437027705392171762931767523846748184676694051 32000568127145263560827785771342757789609173637178 72146844090122495343014654958537105079227968925892 35420199561121290219608640344181598136297747713099 60518707211349999998372978049951059731732816096318 59502445945534690830264252230825334468503526193118 81710100031378387528865875332083814206171776691473 03598253490428755468731159562863882353787593751957 78185778053217122680661300192787661119590921642019 89380952572010654858632788659361533818279682303019 52035301852968995773622599413891249721775283479131 51557485724245415069595082953311686172785588907509 83817546374649393192550604009277016711390098488240 12858361603563707660104710181942955596198946767837 44944825537977472684710404753464620804668425906949 12933136770289891521047521620569660240580381501935 11253382430035587640247496473263914199272604269922 79678235478163600934172164121992458631503028618297 45557067498385054945885869269956909272107975093029 55321165344987202755960236480665499119881834797753 56636980742654252786255181841757467289097777279380 00816470600161452491921732172147723501414419735685 48161361157352552133475741849468438523323907394143 33454776241686251898356948556209921922218427255025 42568876717904946016534668049886272327917860857843 83827967976681454100953883786360950680064225125205 11739298489608412848862694560424196528502221066118 63067442786220391949450471237137869609563643719172 87467764657573962413890865832645995813390478027590 09946576407895126946839835259570982582262052248940 77267194782684826014769909026401363944374553050682 03496252451749399651431429809190659250937221696461 51570985838741059788595977297549893016175392846813 82686838689427741559918559252459539594310499725246 80845987273644695848653836736222626099124608051243 8843904512441365497627807977156914359977001296160 894416948685558484063534220722258284886481584560285 0601684273945226746767889525213852254995466672782 398645659611635488623057745649803559363456817432411 25150760694794510965960940252288797108931456691368 67228748940560101503308617928680920874760917824938 58900971490967598526136554978189312978482168299894 87226588048575640142704775551323796414515237462343 64542858444795265867821051141354735739523113427166 10213596953623144295248493718711014576540359027993 44037420073105785390621983874478084784896833214457 13868751943506430218453191048481005370614680674919 2781911979399520614196634287544406437451237181921 799983910159195618146751426912397489409071864942319 6156794520809514655022523160388193014209376213785 595663893778708303906979207734672218256259966150142 15030680384477345492026054146659252014974428507325 18666002132434088190710486331734649651453905796268 56100550810665879699816357473638405257145910289706 41401109712062804390397595156771577004203378699360 07230558763176359421873125147120532928191826186125 86732157919841484882916447060957527069572209175671 1672291098169091528017350671274858322287183520935 396572512108357915136988209144421006751033467110314 12671113699086585163983150197016515116851714376576 18351556508849099898599823873455283316355076479185 35893226185489632132933089857064204675259070915481 41654985946163718027098199430992448895757128289059 23233260972997120844335732654893823911932597463667 30583604142813883032038249037589852437441702913276 56180937734440307074692112019130203303801976211011 00449293215160842444859637669838952286847831235526 58213144957685726243344189303968642624341077322697 8028073189154411010446823252716201052652272111660 396665573092547110557853763466820653109896526918620 56476931257058635662018558100729360659876486117910 45334885034611365768675324944166803962657978771855 60845529654126654085306143444318586769751456614068 00700237877659134401712749470420562230538994561314 07112700040785473326993908145466464588079727082668 30634328587856983052358089330657574067954571637752 54202114955761581400250126228594130216471550979259 23099079654737612551765675135751782966645477917450 11299614890304639947132962107340437518957359614589 0193897131117904297828564750320319869151402870808 599048010941214722131794764777262241425485454033215 71853061422881375850430633217518297986622371721591 60771669254748738986654949450114654062843366393790 03976926567214638530673609657120918076383271664162 7488880078692560290228472104031721186082041900042 296617119637792133757511495950156604963186294726547 36425230817703675159067350235072835405670403867435 13622224771589150495309844489333096340878076932599 39780541934144737744184263129860809988868741326047 21569516239658645730216315981931951673538129741677 29478672422924654366800980676928238280689964004824 35403701416314965897940924323789690706977942236250 82216889573837986230015937764716512289357860158816 17557829735233446042815126272037343146531977774160 31990665541876397929334419521541341899485444734567 38316249934191318148092777710386387734317720754565 45322077709212019051660962804909263601975988281613 32316663652861932668633606273567630354477628035045 07772355471058595487027908143562401451718062464362 67945612753181340783303362542327839449753824372058 35311477119926063813346776879695970309833913077109 87040859133746414428227726346594704745878477872019 27715280731767907707157213444730605700733492436931 13835049316312840425121925651798069411352801314701 30478164378851852909285452011658393419656213491434 15956258658655705526904965209858033850722426482939 72858478316305777756068887644624824685792603953527 73480304802900587607582510474709164396136267604492 56274204208320856611906254543372131535958450687724 60290161876679524061634252257719542916299193064553 77991403734043287526288896399587947572917464263574 55254079091451357111369410911939325191076020825202 61879853188770584297259167781314969900901921169717 37278476847268608490033770242429165130050051683233 64350389517029893922334517220138128069650117844087 45196012122859937162313017114448464090389064495444 00619869075485160263275052983491874078668088183385 10228334508504860825039302133219715518430635455007 66828294930413776552793975175461395398468339363830 47461199665385815384205685338621867252334028308711 23282789212507712629463229563989898935821167456270 10218356462201349671518819097303811980049734072396 10368540664319395097901906996395524530054505806855 01956730229219139339185680344903982059551002263535 36192041994745538593810234395544959778377902374216 17271117236434354394782218185286240851400666044332 5888569867054315470696574745855033232334210730154 594051655379068662733379958511562578432298827372319 89875714159578111963583300594087306812160287649628 67446047746491599505497374256269010490377819868359 38146574126804925648798556145372347867330390468838 34363465537949864192705638729317487233208376011230 29911367938627089438799362016295154133714248928307 22012690147546684765357616477379467520049075715552 78196536213239264061601363581559074220202031872776 05277219005561484255518792530343513984425322341576 23361064250639049750086562710953591946589751413103 48227693062474353632569160781547818115284366795706 11086153315044521274739245449454236828860613408414 86377670096120715124914043027253860764823634143346 23518975766452164137679690314950191085759844239198 62916421939949072362346468441173940326591840443780 51333894525742399508296591228508555821572503107125 70126683024029295252201187267675622041542051618416 34847565169998116141010029960783869092916030288400 26910414079288621507842451670908700069928212066041 83718065355672525325675328612910424877618258297651 57959847035622262934860034158722980534989650226291 74878820273420922224533985626476691490556284250391 27577102840279980663658254889264880254566101729670 26640765590429099456815065265305371829412703369313 78517860904070866711496558343434769338578171138645 5873678123014587687126603489139095620099393610310 291616152881384379099042317473363948045759314931405 29763475748119356709110137751721008031559024853090 66920376719220332290943346768514221447737939375170 34436619910403375111735471918550464490263655128162 28824462575916333039107225383742182140883508657391 77150968288747826569959957449066175834413752239709 68340800535598491754173818839994469748676265516582 7658483588453142775687900290951702835297163445621 296404352311760066510124120065975585127617858382920 41974844236080071930457618932349229279650198751872 12726750798125547095890455635792122103334669749923 56302549478024901141952123828153091140790738602515 22742995818072471625916685451333123948049470791191 53267343028244186041426363954800044800267049624820 17928964766975831832713142517029692348896276684403 23260927524960357996469256504936818360900323809293 45958897069536534940603402166544375589004563288225 05452556405644824651518754711962184439658253375438 8569094113031509526179378002974120766514793942590 298969594699556576121865619673378623625612521632086 28692221032748892186543648022967807057656151446320 46927906821207388377814233562823608963208068222468 01224826117718589638140918390367367222088832151375 56003727983940041529700287830766709444745601345564 17254370906979396122571429894671543578468788614445 81231459357198492252847160504922124247014121478057 34551050080190869960330276347870810817545011930714 12233908663938339529425786905076431006383519834389 34159613185434754649556978103829309716465143840700 70736041123735998434522516105070270562352660127648 48308407611830130527932054274628654036036745328651 05706587488225698157936789766974220575059683440869 73502014102067235850200724522563265134105592401902 74216248439140359989535394590944070469120914093870 01264560016237428802109276457931065792295524988727 58461012648369998922569596881592056001016552563756
    2.489 seconds elapsed. ok

    No idea if it's correct :--)

    Looks good:
    https://www.math.utah.edu/~pa/math/pi.html

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From dxforth@21:1/5 to Marcel Hendrix on Tue Sep 5 09:27:13 2023
    On 5/09/2023 3:14 am, Marcel Hendrix wrote:
    [..]
    58461012648369998922569596881592056001016552563756
    2.489 seconds elapsed. ok

    No idea if it's correct :--)

    After only 1000 digits? One would hope so. Otherwise what would
    be the value of having a 64-bit cpu? Using mixed-math on a 16-bit
    machine it's possible to generate around 45,000 digits accurately
    using Machin's formula before arithmetic overflow. So the question
    isn't whether 1000 digits is accurate but rather, when does it fails
    and what was the cause.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Marcel Hendrix@21:1/5 to dxforth on Tue Sep 5 04:51:32 2023
    On Tuesday, September 5, 2023 at 1:27:17 AM UTC+2, dxforth wrote:
    On 5/09/2023 3:14 am, Marcel Hendrix wrote:
    [..]
    58461012648369998922569596881592056001016552563756
    2.489 seconds elapsed. ok

    No idea if it's correct :--)
    After only 1000 digits? One would hope so. Otherwise what would
    be the value of having a 64-bit cpu? Using mixed-math on a 16-bit
    machine it's possible to generate around 45,000 digits accurately
    using Machin's formula before arithmetic overflow. So the question
    isn't whether 1000 digits is accurate but rather, when does it fails
    and what was the cause.

    That is what I meant: there could be an implementation problem.
    (I'm now certain its correct upto 10,000 digits.)

    -marcel

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ron AARON@21:1/5 to Marcel Hendrix on Tue Sep 5 15:55:08 2023
    I've just created an app that shows* 45,000 digits of pi in just 0.025s!

    8th -ee '"pi_dec_1m.txt" f:slurp 0 45000 b:slice >s . cr'


    * you need to have downloaded 'pi_dec_1m.txt' first...

    On 05/09/2023 14:51, Marcel Hendrix wrote:
    On Tuesday, September 5, 2023 at 1:27:17 AM UTC+2, dxforth wrote:
    On 5/09/2023 3:14 am, Marcel Hendrix wrote:
    [..]
    58461012648369998922569596881592056001016552563756
    2.489 seconds elapsed. ok

    No idea if it's correct :--)
    After only 1000 digits? One would hope so. Otherwise what would
    be the value of having a 64-bit cpu? Using mixed-math on a 16-bit
    machine it's possible to generate around 45,000 digits accurately
    using Machin's formula before arithmetic overflow. So the question
    isn't whether 1000 digits is accurate but rather, when does it fails
    and what was the cause.

    That is what I meant: there could be an implementation problem.
    (I'm now certain its correct upto 10,000 digits.)

    -marcel

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From minforth@21:1/5 to Ron AARON on Tue Sep 5 23:15:17 2023
    Ron AARON schrieb am Dienstag, 5. September 2023 um 14:55:11 UTC+2:
    I've just created an app that shows* 45,000 digits of pi in just 0.025s!

    Now you should be able to confirm that
    ... the millionth digit of pi after the decimal point is a '1' ...
    without wrecking your electricity bill ;-)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ron AARON@21:1/5 to minforth on Wed Sep 6 15:35:21 2023
    On 06/09/2023 9:15, minforth wrote:
    Ron AARON schrieb am Dienstag, 5. September 2023 um 14:55:11 UTC+2:
    I've just created an app that shows* 45,000 digits of pi in just 0.025s!

    Now you should be able to confirm that
    ... the millionth digit of pi after the decimal point is a '1' ...
    without wrecking your electricity bill ;-)

    Exactly :)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From dxforth@21:1/5 to Ron AARON on Wed Sep 6 23:35:53 2023
    On 6/09/2023 10:35 pm, Ron AARON wrote:
    On 06/09/2023 9:15, minforth wrote:
    Ron AARON schrieb am Dienstag, 5. September 2023 um 14:55:11 UTC+2:
    I've just created an app that shows* 45,000 digits of pi in just 0.025s!

    Now you should be able to confirm that
    ... the millionth digit of pi after the decimal point is a '1' ...
    without wrecking your electricity bill  ;-)

    Exactly :)

    The computer that calculates PI is not the problem. It's the computer
    that is connected to the internet that drains money :)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From S Jack@21:1/5 to dxforth on Wed Sep 6 14:14:23 2023
    On Wednesday, September 6, 2023 at 8:35:57 AM UTC-5, dxforth wrote:
    On 6/09/2023 10:35 pm, Ron AARON wrote:
    On 06/09/2023 9:15, minforth wrote:
    Ron AARON schrieb am Dienstag, 5. September 2023 um 14:55:11 UTC+2:
    I've just created an app that shows* 45,000 digits of pi in just 0.025s! >>
    Now you should be able to confirm that
    ... the millionth digit of pi after the decimal point is a '1' ...
    without wrecking your electricity bill ;-)

    Exactly :)T> The computer that calculates PI is not the problem. It's the computer
    that is connected to the internet that drains money :)

    There is a town in Texas where a company is bit coin mining. The company consumes more power than all the
    homes in the town.
    --
    me

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Marcel Hendrix@21:1/5 to S Jack on Wed Sep 6 21:50:42 2023
    On Wednesday, September 6, 2023 at 11:14:26 PM UTC+2, S Jack wrote:
    On Wednesday, September 6, 2023 at 8:35:57 AM UTC-5, dxforth wrote:
    [..]
    Exactly :)T> The computer that calculates PI is not the problem. It's the computer
    that is connected to the internet that drains money :)
    There is a town in Texas where a company is bit coin mining. The company consumes more power than all the
    homes in the town.

    A company? If you go that far, the persons with the spreadsheets will increase the size of the facility until you consume all the power that is available without
    huge price jumps (and maybe even then). The town probably willingly subsidizes them.

    -marcel

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From minforth@21:1/5 to Marcel Hendrix on Thu Sep 7 00:46:25 2023
    Marcel Hendrix schrieb am Donnerstag, 7. September 2023 um 06:50:44 UTC+2:
    On Wednesday, September 6, 2023 at 11:14:26 PM UTC+2, S Jack wrote:
    On Wednesday, September 6, 2023 at 8:35:57 AM UTC-5, dxforth wrote:
    [..]
    Exactly :)T> The computer that calculates PI is not the problem. It's the computer
    that is connected to the internet that drains money :)
    There is a town in Texas where a company is bit coin mining. The company consumes more power than all the
    homes in the town.
    A company? If you go that far, the persons with the spreadsheets will increase
    the size of the facility until you consume all the power that is available without
    huge price jumps (and maybe even then). The town probably willingly subsidizes
    them.

    I read that the whole Chinese province north of Beijing (called inner Mongolia)
    consumed more electricity for bitcoin mining than for anything else (illegal power
    theft not counted) during the covid pandemy. Regarding the "conditions" of many of their coal-fired power plants (I've been there) the CO2 impact is gigantic.

    Good that our government is now deindustrializing our country to compensate that.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)