diff options
Diffstat (limited to 'macros/generic/poormanlog/README')
-rw-r--r-- | macros/generic/poormanlog/README | 153 |
1 files changed, 52 insertions, 101 deletions
diff --git a/macros/generic/poormanlog/README b/macros/generic/poormanlog/README index fc5f096fdc..cb250c4adf 100644 --- a/macros/generic/poormanlog/README +++ b/macros/generic/poormanlog/README @@ -1,126 +1,77 @@ -DOCUMENTATION OF POORMANLOG (v0.04, 2019/02/17) -=========================== +POORMANLOG (v0.05, 2019/04/22) +============================== -(see License at bottom of this file) +poormanlog.tex provides (expandable) macros \PMLogZ and \PMPowTen +for computing base 10 logarithms and powers of 10 with a bit less +than 9 digits of precision. -The poormanlog.tex file has no dependencies. It provides (expandable) -macros for base 10 logarithms and powers of 10 with a bit less than 9 -digits of precision (\PMLogZ and \PMPowTen), but its main use will be -in conjunction with xintexpr.sty, as it provides to the latter -functions log10() and pow10() and does on-demand modification of the -power operators ** or ^ to compute according to pow10(y*log10(x)). +It can be used with TeX (\input poormanlog) and has a LaTeX interface +(\usepackage{poormanlog}). -This usage will become obsolete when xintexpr will natively implement -in arbitrary precision the log10() and pow10() functions. +Regarding TeX, it requires the e-TeX \numexpr primitive, thus etex +or pdftex or other binaries with the e-TeX extensions are required. -The file can be used with Plain TeX (\input poormanlog) or as a -regular LaTeX package. +Changes +------- -Example (with Plain TeX) ------------------------- - - \input xintexpr.sty - \input poormanlog.tex - - \xinteval{log10(3.14159265), pow10(2.71828183)} - - \poormanloghack{**} - - \xinteval{3.14159265**2.71828183} - - \poormanloghack{^} - - \xinteval{3.14159265^2.71828183} - - \bye - - -User interface --------------- - -\PMLogZ{#1} expands in two steps. - -input: #1 is a mantissa ddddddddd (it may be an f-expandable macro) - with exactly 9 digits (the first one must not be zero) -output: 9 digits xxxxxxxxx such that log10(d.dddddddd) is about 0.xxxxxxxxx - -It seems from testing that absolute error is not much more than 1 unit in -the last place, and result differs from rounded mathematical value by at -most 1 unit in the 9th digit. (attention not rigorously proven). - -\PMPowTen{#1} expands in two steps. - -input: #1 is (or expands to) exactly 9 digits ddddddddd representing - 0.ddddddddd -output: 9 digits xxxxxxxxx, first one not zero, - such that 10^0.ddddddddd is about x.xxxxxxxx - -It seems from testing that absolute error is less than 2 units in -the last place, and result differs from rounded mathematical value by at -most 2 units in the 9th digit. (attention not rigorously proven). - -\PoorManLogBaseTen{#1} - - in presence of xintfrac this will accept input as recognized by xintfrac - and produce the logarithm in base 10 with an error (believed to be at - most) about 1 unit in the 9th (i.e. last) fractional digit. - - xintfrac may be loaded before or after. - -\PoorManPowerOfTen{#1} - - in presence of package xintfrac this will accept input as recognized by - xintfrac and produce the 10^#1 with 9 digits of float precision, with an - error (believed to be) at most 2 units in the last place. Of course for - this the input must be precise enough to have 9 fractional digits of - **fixed point** precision. +- v0.04 (2019/02/17): initial release. The package has no + dependencies and alongside two macros \PMLogZ and \PMPowTen + also provides some specific additions to xint. - xintfrac may be loaded before or after. +- v0.05 (2019/04/22): the additions/patches to xint originally + provided by poormanlog.tex got moved into xint 1.3f itself. -\PoorManPower{#1}{#2} + Thus, poormanlog now reduces to the sole two macros + \PMLogZ and \PMPowTen. It can be imported by other macro + files with no danger of conflicting with future releases of + xint in case of concurrent usage. - in presence of package xintfrac computes #1 to the power #2 - xintfrac may be loaded before or after. +Files +----- -log10() +poormanlog.tex +poormanlog.sty +README - the log10() function is made available, if xintexpr.sty is loaded, for - usage within \xinteval and \xintfloateval. If a log10() function is - already defined in xintexpr it will not be overwritten - xintexpr may be loaded before or after. +\PMLogZ{#1} computes base-10 logarithms: +---------------------------------------- -pow10() +expansion: the argument is submitted to f-expansion and the macro + itself expands fully in two steps. - pow10() function is made available, if xintexpr.sty is loaded, for usage - within \xinteval and \xintfloateval. If a pow10() function is already - defined in xintexpr it will not be overwritten +input: #1 must be (or f-expands to) a mantissa ddddddddd with exactly + 9 digits, standing for D = d.dddddddd, 1 <= D < 10 - xintexpr may be loaded before or after. +output: 9 digits xxxxxxxxx standing for X = 0.xxxxxxxxx such that + log10(D) is about X -modification of ** or ^ operators in \xintexpr and \xintfloatexpr +precision: It seems from testing that absolute error is not much + more than 1 unit in the last place, and result X differs + from rounded mathematical value of log10(D) by at most + 1 unit in the last place. + (*attention estimate not rigorously proven*). - \poormanloghack{**} - \poormanloghack{^} - They will now use pow10(y*log10(x)) formula to compute x to the power y +\PMPowTen{#1} computes fractional powers of 10: +----------------------------------------------- - Of course this means drop of precision, but allows non-integer exponents. - (half-integer exponents are already accepted in \xintfloatexpr natively). +expansion: the argument is submitted to f-expansion and the macro + itself expands fully in two steps. - ** xintexpr must have been loaded before ** +input: #1 must be (f-expands to) exactly 9 digits xxxxxxxxx, standing + for X = 0.xxxxxxxxx -Example with LaTeX : +output: 9 digits ddddddddd, such that D = d.dddddddd is about 10^X + The first digit of output is never zero (i.e. 1 <= D < 10) - \documentclass{article} - \usepackage{xintexpr} - \usepackage{poormanlog}% makes log10() and pow10() available - \poormanloghack{**} % modifies ** operator - \begin{document} - \xinteval{3.14159265**2.71828183, log10(3.14159265), pow10(2.71828)} - \end{document} +precision: It seems from testing that absolute error is less than + 2 units in the last place, and result D differs from + rounded mathematical value of 10^X by at most 2 units in + the last place. + (*attention estimate not rigorously proven*). LICENSE @@ -141,5 +92,5 @@ This Work has the LPPL maintenance status `author-maintained'. The Author of this Work is Jean-Francois Burnol. -This Work consists of files poormanlog.tex, poormanlog.sty and the +This Work consists of files poormanlog.tex, poormanlog.sty and this README. |