Index of /macros/generic/poormanlog
      Name                    Last modified       Size  Description

[DIR] Parent Directory 22-Aug-2019 07:27 - [TXT] poormanlog.sty 18-Feb-2019 02:13 1k [TXT] poormanlog.tex 18-Feb-2019 02:08 14k

DOCUMENTATION OF POORMANLOG (v0.04, 2019/02/17)
===========================

(see License at bottom of this file)

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)).

This usage will become obsolete when xintexpr will natively implement
in arbitrary precision the log10() and pow10() functions.

The file can be used with Plain TeX (\input poormanlog) or as a
regular LaTeX package.


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.

  xintfrac may be loaded before or after.

\PoorManPower{#1}{#2}

  in presence of package xintfrac computes #1 to the power #2

  xintfrac may be loaded before or after.

log10()

  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.

pow10()

  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

  xintexpr may be loaded before or after.

modification of ** or ^ operators in \xintexpr and \xintfloatexpr

  \poormanloghack{**}
  \poormanloghack{^}

  They will now use pow10(y*log10(x)) formula to compute x to the power y

  Of course this means drop of precision, but allows non-integer exponents.
  (half-integer exponents are already accepted in \xintfloatexpr natively).

  ** xintexpr must have been loaded before **

Example with LaTeX :

    \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}


LICENSE
-------

Copyright (C) 2019, Jean-Francois Burnol.

This Work may be distributed and/or modified under the conditions of the
LaTeX Project Public License version 1.3c. This version of this license
is in

    <http://www.latex-project.org/lppl/lppl-1-3c.txt>

and version 1.3 or later is part of all distributions of LaTeX version
2005/12/01 or later.

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
README.