texlive[52080] Master/texmf-dist: poormanlog (11sep19)
commits+karl at tug.org
commits+karl at tug.org
Wed Sep 11 23:20:04 CEST 2019
Revision: 52080
http://tug.org/svn/texlive?view=revision&revision=52080
Author: karl
Date: 2019-09-11 23:20:03 +0200 (Wed, 11 Sep 2019)
Log Message:
-----------
poormanlog (11sep19)
Modified Paths:
--------------
trunk/Master/texmf-dist/doc/generic/poormanlog/README
trunk/Master/texmf-dist/tex/generic/poormanlog/poormanlog.sty
trunk/Master/texmf-dist/tex/generic/poormanlog/poormanlog.tex
Modified: trunk/Master/texmf-dist/doc/generic/poormanlog/README
===================================================================
--- trunk/Master/texmf-dist/doc/generic/poormanlog/README 2019-09-11 21:19:52 UTC (rev 52079)
+++ trunk/Master/texmf-dist/doc/generic/poormanlog/README 2019-09-11 21:20:03 UTC (rev 52080)
@@ -1,128 +1,79 @@
-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)
-------------------------
+- 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.
- \input xintexpr.sty
- \input poormanlog.tex
+- v0.05 (2019/04/22): the additions/patches to xint originally
+ provided by poormanlog.tex got moved into xint 1.3f itself.
- \xinteval{log10(3.14159265), pow10(2.71828183)}
+ 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.
- \poormanloghack{**}
- \xinteval{3.14159265**2.71828183}
+Files
+-----
- \poormanloghack{^}
+poormanlog.tex
+poormanlog.sty
+README
- \xinteval{3.14159265^2.71828183}
- \bye
+\PMLogZ{#1} computes base-10 logarithms:
+----------------------------------------
+expansion: the argument is submitted to f-expansion and the macro
+ itself expands fully in two steps.
-User interface
---------------
+input: #1 must be (or f-expands to) a mantissa ddddddddd with exactly
+ 9 digits, standing for D = d.dddddddd, 1 <= D < 10
-\PMLogZ{#1} expands in two steps.
+output: 9 digits xxxxxxxxx standing for X = 0.xxxxxxxxx such that
+ log10(D) is about X
-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
+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*).
-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.
+\PMPowTen{#1} computes fractional powers of 10:
+-----------------------------------------------
-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
+expansion: the argument is submitted to f-expansion and the macro
+ itself expands fully in two steps.
-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).
+input: #1 must be (f-expands to) exactly 9 digits xxxxxxxxx, standing
+ for X = 0.xxxxxxxxx
-\PoorManLogBaseTen{#1}
+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)
- 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.
+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*).
- 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
-------
@@ -141,5 +92,5 @@
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.
Modified: trunk/Master/texmf-dist/tex/generic/poormanlog/poormanlog.sty
===================================================================
--- trunk/Master/texmf-dist/tex/generic/poormanlog/poormanlog.sty 2019-09-11 21:19:52 UTC (rev 52079)
+++ trunk/Master/texmf-dist/tex/generic/poormanlog/poormanlog.sty 2019-09-11 21:20:03 UTC (rev 52080)
@@ -1,4 +1,4 @@
-%% poormanlog.sty v0.04, 2019/02/17
+%% poormanlog.sty v0.05, 2019/04/22
%%
%% Copyright (C) 2019, Jean-Francois Burnol
%%
@@ -12,6 +12,6 @@
%% This Work consists of files poormanlog.tex, poormanlog.sty and
%% the accompanying README
%%
-\ProvidesPackage{poormanlog}[2019/02/17 v0.04 log and powers with 9 digits (JFB)]
+\ProvidesPackage{poormanlog}[2019/04/22 v0.05 base 10 log and pow with 9 digits (JFB)]
\input{poormanlog.tex}% see README file for user documentation
\endinput
Modified: trunk/Master/texmf-dist/tex/generic/poormanlog/poormanlog.tex
===================================================================
--- trunk/Master/texmf-dist/tex/generic/poormanlog/poormanlog.tex 2019-09-11 21:19:52 UTC (rev 52079)
+++ trunk/Master/texmf-dist/tex/generic/poormanlog/poormanlog.tex 2019-09-11 21:20:03 UTC (rev 52080)
@@ -1,4 +1,4 @@
-%% poormanlog.tex v0.04, 2019/02/17
+%% poormanlog.tex v0.05, 2019/04/22
%%
%% Copyright (C) 2019, Jean-Francois Burnol
%%
@@ -12,11 +12,6 @@
%% This Work consists of files poormanlog.tex, poormanlog.sty and the
%% README
%%
-%% ************ BARELY TESTED ****************
-%% >>>>>>> WARNING FOR LACK OF TIME I HAVE NOT YET VALIDATED FULLY <<<<<
-%% >>>>>>> NOR HAVE I MADE PRECISE ESTIMATES. USE AT YOUR OWN RISK <<<<<
-%% (bug reports welcome)
-%% ************ BARELY TESTED ****************
%
% Package macro private prefix: \PML@
%
@@ -35,7 +30,7 @@
\catcode`\noexpand\^ \the\catcode`\^ %
\catcode`\noexpand\: \the\catcode`\: %
\catcode`\noexpand\* \the\catcode`\* %
- \catcode`\noexpand\@ \the\catcode`\@ %
+ \catcode`\noexpand\@ \the\catcode`\@\relax
}%
\catcode`\@ 11 %
\if1\ifx\@namedef\JFBUundefined1\else\ifx\@namedef\relax1\else0\fi\fi
@@ -284,138 +279,5 @@
\the\numexpr1000000000+\expandafter\PML@\romannumeral-`0#1.\relax
}%
\def\PMPowTen#1{\the\numexpr\expandafter\PML at Pa\romannumeral-`0#1.\relax}%
-%%
-%%
-%% ADD-ONS TO XINTFRAC : \PoorManLogBaseTen{#1}, \PoorManPowerOfTen{#1}
-%% and \PoorManPower{#1}{#2}
-%% Does not matter if xintfrac loaded before or after.
-%%
-\def\PoorManLogBaseTen{\romannumeral0\poormanlogbaseten}%
-\def\poormanlogbaseten #1%
- {\expandafter\PML at logbaseten\romannumeral0\XINTinfloat[9]{#1}}%
-\def\PML at logbaseten#1[#2]%
-{%
- \xintiiadd{\xintDSx{-9}{\the\numexpr#2+8\relax}}{\the\numexpr\PML@#1.}%
- [-9]%
-}%
-%
-\def\PoorManPowerOfTen{\the\numexpr\poormanpoweroften}%
-\def\poormanpoweroften #1%
- {\expandafter\PML at powoften\romannumeral0\xintraw{#1}}%
-\catcode`\_ 11 %
-\def\PML at powoften#1{%
- \xint_UDzerominusfork
- #1-\PML at powoften@zero
- 0#1\PML at powoften@neg
- 0-\PML at powoften@pos
- \krof #1%
-}%
-\catcode`\_ 8 %
-\def\PML at powoften@zero 0{1\relax}%/1[0]
-\def\PML at powoften@pos#1[#2]{%
- \expandafter\PML at powoften@pos at a\romannumeral0\xintround{9}{#1[#2]}.%
-}%
-\def\PML at powoften@pos at a#1.#2.{\PML at Pa#2.\expandafter[\the\numexpr-8+#1]}%
-\def\PML at powoften@neg#1[#2]{%
- \expandafter\PML at powoften@neg at a\romannumeral0\xintround{9}{#1[#2]}.%
-}%
-\def\PML at powoften@neg at a#1.#2.{\ifnum#2=0 \xint_afterfi{1\relax/1[#1]}\else
- \expandafter\expandafter\expandafter
- \PML at Pa\expandafter\@gobble\the\numexpr2000000000-#2.%
- \expandafter[\the\numexpr-9+#1\expandafter]\fi
-}%
-%
-\def\PoorManPower#1#2% #1**#2
-{%
- \PoorManPowerOfTen{\xintMul{#2}{\PoorManLogBaseTen{#1}}}%
-}%
-%%
-%% ADD-ONS TO XINTEXPR :
-%%
-%% log10(), pow10()
-%%
-%% Does not matter if xintexpr loaded before or after.
-%%
-\catcode`\_ 11 \catcode`\: 11 %
-\unless\ifcsname XINT_expr_func_log10\endcsname
-\@namedef{XINT_expr_func_log10}#1#2#3%
-{%
- \expandafter #1\expandafter #2\csname.=%
- \XINT:NEhook:one\PoorManLogBaseTen{\XINT_expr_unlock #3}\endcsname
-}%
-\fi
-\unless\ifcsname XINT_flexpr_func_log10\endcsname
-\expandafter\let\csname XINT_flexpr_func_log10\expandafter\endcsname
- \csname XINT_expr_func_log10\endcsname
-\fi
-%
-\unless\ifcsname XINT_expr_func_pow10\endcsname
-\@namedef{XINT_expr_func_pow10}#1#2#3%
-{%
- \expandafter #1\expandafter #2\csname.=%
- \XINT:NEhook:one\PoorManPowerOfTen{\XINT_expr_unlock #3}\endcsname
-}%
-\fi
-\unless\ifcsname XINT_flexpr_func_pow10\endcsname
-\expandafter\let\csname XINT_flexpr_func_pow10\expandafter\endcsname
- \csname XINT_expr_func_pow10\endcsname
-\fi
-%%
-%% On-demand modification of ** or ^ operators in \xintexpr and \xintfloatexpr
-%%
-\catcode`\* 11 \catcode0 12 %
-%
-\def\poormanloghack**{%
-\def\XINT_expr_op_** ##1%
-{%
- \expandafter \XINT_expr_until_**_a
- \expandafter ##1\romannumeral`^^@\expandafter\XINT_expr_getnext
-}%
-\def\XINT_expr_until_**_a ##1{%
-\def\XINT_expr_until_**_a ####1####2%
-{%
- \xint_UDsignfork
- ####2{\expandafter \XINT_expr_until_**_a \expandafter ##1%
- \romannumeral`^^@##1}%
- -{\XINT_expr_until_**_b ####1####2}%
- \krof
-}}\expandafter\XINT_expr_until_**_a\csname XINT_expr_op_-ix\endcsname
-\def\XINT_expr_until_**_b ##1##2##3##4%
-{%
- \ifnum ##2>\XINT_expr_precedence_**
- \xint_afterfi
- {\expandafter \XINT_expr_until_**_a \expandafter ##1%
- \romannumeral`^^@\csname XINT_expr_op_##3\endcsname {##4}}%
- \else
- \xint_afterfi
- {\expandafter ##2\expandafter ##3%
- \csname .=\XINT:NEhook:two
- \PoorManPower{\XINT_expr_unlock ##1}{\XINT_expr_unlock ##4}\endcsname
- }%
- \fi
-}%
-\let\XINT_flexpr_op_** \XINT_expr_op_**
-\let\XINT_flexpr_until_**_a\XINT_expr_until_**_a
-\let\XINT_flexpr_until_**_b\XINT_expr_until_**_b
-}%
-\catcode`\^ 11 \catcode`\* 7 %
-\def\poormanloghack^{%
-\def\XINT_expr_until_^_b ##1##2##3##4%
-{%
- \ifnum ##2>\XINT_expr_precedence_^
- \xint_afterfi
- {\expandafter \XINT_expr_until_^_a \expandafter ##1%
- \romannumeral`**@\csname XINT_expr_op_##3\endcsname {##4}}%
- \else
- \xint_afterfi
- {\expandafter ##2\expandafter ##3%
- \csname .=\XINT:NEhook:two
- \PoorManPower{\XINT_expr_unlock ##1}{\XINT_expr_unlock ##4}\endcsname
- }%
- \fi
-}%
-\let\XINT_flexpr_until_^_b\XINT_expr_until_^_b
-}%
\@tempa
-\def\poormanloghack#1{\csname poormanloghack#1\endcsname}%
\endinput
More information about the tex-live-commits
mailing list