• Re: (expt 9.5 400) and (expt 9.4721 400)

    From Hen Hanna@21:1/5 to Hen Hanna on Sat Jun 18 09:03:32 2022
    On Saturday, June 18, 2022 at 8:52:41 AM UTC-7, Hen Hanna wrote:
    here using Gauche implementation of Scheme (Lisp)
    _________________________

    gosh> (expt 2 10)
    1024

    gosh> (expt 95 400) 1228689411151797377107717634224064803017575401398594588081091244670709854466364326011242261981383723848271368357476398249572178725662842705849705738067097192763877207173384919377689401253418588182329215464703671057451590509007387328576411779739341993599
    752833040406622145278927545812514720285505733774659741495247769070536474872762186309159914033931759188077215423520520619318283889372444128681783581571013551868238156797463367602331228036649305971669358765813829360486619224951775038149982711801260166157410
    290484217183995508850610364533988509893842212304967606677253437556213561106464392018000241016837839257995692713754739481661299043657628565395065047389099127939725281076965439499556839576998901966443317149538889596110258286379942421506743238527117889624662
    43901872076094150543212890625

    gosh> (expt 9.5 300) --> 2.075303347768084e293

    gosh> (expt 9.5 400) --> +inf.0


    SO... With ( 9.5 ^ 400) i can get the exact value, but
    what i want to do is to get an approx. value of

    ( A ^ 400 ) where

    A is 9.47213595499958
    or
    A is (+ 5 (* 2 (sqrt 5)))



    is there a way to do this?


    (expt 947213595499958 400) gives me an approx value,
    but i guess i'm asking for 1000 or million times as many digits.

    so it seems far beyond what my cheap PC can do.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Hen Hanna@21:1/5 to All on Sat Jun 18 08:52:37 2022
    here using Gauche implementation of Scheme (Lisp)
    _________________________

    gosh> (expt 2 10)
    1024

    gosh> (expt 95 400) 122868941115179737710771763422406480301757540139859458808109124467070985446636432601124226198138372384827136835747639824957217872566284270584970573806709719276387720717338491937768940125341858818232921546470367105745159050900738732857641177973934199359975
    283304040662214527892754581251472028550573377465974149524776907053647487276218630915991403393175918807721542352052061931828388937244412868178358157101355186823815679746336760233122803664930597166935876581382936048661922495177503814998271180126016615741029
    048421718399550885061036453398850989384221230496760667725343755621356110646439201800024101683783925799569271375473948166129904365762856539506504738909912793972528107696543949955683957699890196644331714953888959611025828637994242150674323852711788962466243
    901872076094150543212890625

    gosh> (expt 9.5 300) --> 2.075303347768084e293

    gosh> (expt 9.5 400) --> +inf.0


    SO... With ( 9.5 ^ 400) i can get the exact value, but
    what i want to do is to get an approx. value of

    ( A ^ 400 ) where

    A is 9.47213595499958
    or
    A is (+ 5 (* 2 (sqrt 5)))



    is there a way to do this?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Paul Rubin@21:1/5 to Hen Hanna on Sat Jun 18 15:32:31 2022
    Hen Hanna <henhanna@gmail.com> writes:
    is there a way to do this?

    The issue is that 9.5**400 is around 1e390 which is larger than the ieee
    fp64 maximum value of around 1e308. While there is an extended format
    with a wider range, it is probably simplest to use logarithms:

    (define (log10 x) (/ (log x) (log 10.0)))

    (define x0 (+ 5 (* 2 (sqrt 5)))) ; 9.472...

    (define y0 (* 400.0 (log10 x0))) ; log10(x0**400)

    (let* ((y1 (floor y0))
    (y2 (- y0 y1)))
    (display `(,(expt 10 y2) "* 10**" ,y1)))
    (newline)

    prints (3.794627652179525 * 10** 390.0) when I try it in Guile.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From James Cloos@21:1/5 to All on Sat Jun 18 18:28:01 2022
    i’m not up on scheme’s details, but with common lisp those floats
    default to single-float, which is usually implemente these days with
    a 32-bit ieee float.

    using l as the delimiter between the significand and the exponent
    will generate a long-float, with more resolution.

    on an arm64 sbc, and using ecl, i get:

    (expt (+ 5l0 (* 2l0 (sqrt 5l0))) 400)

    3.7946276521800698015l390

    for more digits one’d need to use multi-precision floats.

    i have no idea whether any scheme implementations include any mp float
    support as is, but they should let you use an extertnal library such as
    mpfr for that.

    your pc is certainly good enough; you just need the right software.

    (they do not make any these dayswhich are not good enough; not even at
    the sub-$30 price point.)

    In maxima:

    (%i3) (2b0*sqrt(5b0)+5b0)^400b0,fpprec:999;
    (%o3) 3.7946276521800697305666550087536192992115769295190551691665658622025488\ 195527774282584577158133760363054128087496967891514764773751875434079622491760\ 760697880911146535967511959796900645429566665476227663091405183155412705120528\ 107603481804507230138239252996700097573900617537077884807268892365403939464952\ 884993314087737184104485796978046070820564123621254637441779777873307466506958\ 007812499999999999999999999999999999999999999999999999999999999999999999999999\ 999999999999999999999999999999999999999989794540413933744145337696735909814614\ 790479700848425376607266434711262904353407710432649693087316786760610501184349\ 347109985584947803067028202580520987298601120677255115594828007214424540451843\ 222471830925057425575004834959741740703164533089752802924419634880343840285041\ 613337373169098123721455216932346242326642176737006286464924950409814547065789\ 596130406436031620557787620213303967542302476673429612247644081703293433164688\ 6414110731231241578737816677781912052635857679622387021664384404205661b390

    (the b means bfloat, fpprec is the bfloat precision.)

    -JimC
    --
    James Cloos <cloos@jhcloos.com> OpenPGP: 0x997A9F17ED7DAEA6

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