HP Forums

Full Version: (50G) Large Integer to Base 10 Log Programme
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
For integer input the programme BIGLOG returns the log base 10.

eg For input

60972196495985322369469798850801395302233069288389279166718517378288539199086752​53772828395807486955328057711602407909354477975589398740509118499524860455264864​11106037764405463398396472641115525576032228751018736693965754215839199478125969​64270533633515722663098931197911783761324710519769622826678690931698397717528770​80894390480920152306933617442225949410254569970714145285477153695161427987295945​69376188511140560417696406899822332583576409462768935168645399972444071572976928​16417139456756647645884487127633870919566186250410033473994566303930900748694810​30324872370506326060435140434074032858765790837423811563558971220317671898534319​82749631400449968576877886066545103094164391436666145616265619031702920345151684​50637351147189005554917928090509138364148203538729458116306434784561668463437648​14525532563899280752844541535052281746385377077255298591086919833608634670579344​89440006231778216811149416546321827680568766321110496323916077757513765627881957​52629084676115012532176672831536458918920389549244757682931704018959877582875378​60175080145621124941202821174626006127576393656226415478168650461466207770685644​78518346005409730494481172328837615078781553237239677681517994131569687376352654​40209414250942595024112911401104501906901321737665793600952875293931544216860453​91926316738120957733187497367601932891776753311012393210239072877362192595830121​55681857901094932534370554300982366731719013164366540908158744147098586230201288​44328172198171573831859353822145544709467861053167253147641559353356127933542788​75527436179238982122413368768285412750438656000190659579641409153970707078135766​08479883775979420101019523009961171487588479013536059999820953538662246215226863​44058343091513072703175200157752922856174815662295033980304125418288912564841618​61878349931355844200851655210196106934987719418595895899578788448017706334980682​36902225640291247855293005346082930603234305082084758373442773956864325775511203​30341994513746000838363840219610433344021155120705343745170392498048026889718726​

BIGLOG returns

1999.78513184

BIGLOG

::
CK1&Dispatch
# FF
::
DUP
PTR 2F3A3
%1-
SWAP
FPTR2 ^Z>S
DUP
ONEONE
SUB$
CHR_.
>T$
SWAP
CDR$
&$
palparse
DROP
%LOG
%+
;
;
But this is smaller & faster:

Edit: Do not use this programme, see next posting.

::
CK1&Dispatch
# FF
::
DUP
PTR 2F3A3
%1-
SWAP
FPTR2 ^Z>S
BINT1
BINT13
SUB$
FPTR2 ^S>Z
FPTR2 ^Z>R
%MANTISSA
%LOG
%+
;
;
Bug due to roundoff error: the program returns 12 for 9999999999999 (that's 13 nines), and similarly its output is 1 too low for any longer string of 9's.
Thanks for the advice - smaller & faster loses to correct.
Oh dear... hate to be a pest, but I found another bug.

Both programs return 12 for an input of 999999999884 (that's nine 9's followed by 884), but the correct answer is 11.99999999994962184... which should round to 11.9999999999, not 12. Notice that the 50g, Prime Home and Prime CAS all correctly get 11.9999999999 for log10(999999999884).

If this tiny inaccuracy is admissible, forgive my intrusion.
Placing a programme under the spotlight of forum members hopefully finds bugs - thanks Joe for the keen eyes. Are you the only one bothered or interested? I trust the critique from more eyes will produce a finally correct programme - Come on you others!

Meanwhile the amended programme below deals with the immediate error:

::
CK1&Dispatch
# FF
::
DUP
PTR 2F3A3
%1-
SWAP
FPTR2 ^Z>S
DUP
ONEONE
SUB$
CHR_.
>T$
SWAP
CDR$
&$
palparse
DROP
2%>%%
%%LN
%%10
%%LN
%%/
%%+
%%>%
;
;

A drastic remedy for a unique(?) error. Better suggestions?

Signed: Waiting for the next bug whichever pest may find it.
Just for those interested, here a programme taking integer input & returning base ten log as a long real. For the 2,000 digit integer above the programme returned

%% 1.99978513184057E3

PARI answered the same problem with

1999.785131840567325356093351

Name of programme: LONGLOG

::
CK1&Dispatch
# FF
::
DUP
Z0_
Z<=
caseSIZEERR
FPTR2 ^Z>S
DUPLEN$
#1-
OVER
BINT13
1_#1-SUB$
FPTR2 ^S>Z
FPTR2 ^Z>R
%MANTISSA
%>%%
ROT
BINT13
LAST$
CHR_.
>H$
CHR_0
>H$
palparse
DROP
%>%%
%% 1E11
%%/
%%+
%%LN
%%10
%%LN
%%/
SWAP
UNCOERCE%%
%%+
;
;
Hello Gerald H,

Quote:Are you the only one bothered or interested?

Definitly not, but SysRPL is too hard for me. I'm happy to retrace an interesting UserRPL program.
Reference URL's