diff options
author | Karl Berry <karl@freefriends.org> | 2013-01-12 00:02:04 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2013-01-12 00:02:04 +0000 |
commit | cc53d59f49808d6b80420a89e05e3f39ad96412a (patch) | |
tree | f36727477016c8570f3016dd2f2c9f4c3890240b /Master/texmf-dist/doc/generic | |
parent | 84897d5d7dcc5750e11a40c7a1f4d2d2f6154bc7 (diff) |
minifp (11jan13)
git-svn-id: svn://tug.org/texlive/trunk@28804 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/generic')
-rw-r--r-- | Master/texmf-dist/doc/generic/minifp/README | 102 | ||||
-rw-r--r-- | Master/texmf-dist/doc/generic/minifp/minifp.pdf | bin | 0 -> 418427 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/generic/minifp/test1.tex | 480 | ||||
-rw-r--r-- | Master/texmf-dist/doc/generic/minifp/test2.tex | 376 |
4 files changed, 958 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/generic/minifp/README b/Master/texmf-dist/doc/generic/minifp/README new file mode 100644 index 00000000000..f6b413bf9ee --- /dev/null +++ b/Master/texmf-dist/doc/generic/minifp/README @@ -0,0 +1,102 @@ +The MiniFP package + +Purpose: + + minifp.sty defines macros for calculating with decimal real numbers. + It provides 8 decimal digits before and after the decimal point. + Minifp also provides a stack-based "assembly" language for writing + "programs". + + In its basic form, minifp makes only simple operations available. To + get additional operations (sine, cosine, angle, square root, log and + exp), the file mfpextra.tex is provided. + + Minifp should work in both latex and plaintex. + + This is version 0.9. It should work reasonably well, barring any bugs, + but I expect to spend some time fine-tuning it for version 1.0. + +License: + + All files of the minifp distribution (listed below) may be distributed + and/or modified under the conditions of the LaTeX Project Public + License, either version 1.3c of this license or (at your option) any + later version. The latest version of this license is in + http://www.latex-project.org/lppl.txt + and version 1.3c or later is part of all distributions of LaTeX + version 2008/12/01 or later. + + While every effort has been made to make minifp useful, it comes with + no warranty, expressed or implied. + +Usage: + + You can use minifp as a LaTeX package with + \usepackage{minifp} + or use it in plain TeX with + \input minifp.sty + + You can access the extra commands from mfpextra.tex by issuing the + command + \MFPloadextra + after minifp.sty has been loaded. + +Installation: + + To install minifp, obtain minifp.tds.zip from CTAN and unzip it in any + TDS-compliant texmf tree. + + Or, in the presence of minifp.dtx, run tex or latex on minifp.ins to + unpack the files minifp.sty and mfpextra.tex. Copy those files to some + place where both tex and latex can find them. For example, in a TDS + compliant system, the directory /tex/generic/minifp/ under one of your + TEXMF root directories. + + The documentation is provided in minifp.pdf. Put minifp.pdf (and this + README and the files test*.tex, if you wish) wherever documentation of + packages is kept. For example, in the directory /doc/generic/minifp/ + under one of your TEXMF root directories. + + If you wish to regenerate the documentation, run latex (or pdflatex) + on minifp.dtx three times and then + makeindex -s gind.ist -o minifp.ind minifp.idx + and then (pdf)latex again on minifp.dtx. + +Manifest: + + These, together with the files minifp.sty and mfpextra.tex (generated + by tex-ing minifp.ins), constitute the minifp distribution to which the + license applies: + + minifp.dtx Contains minifp.sty and mfpextra.tex + minifp.ins The unpacking script: run tex or latex on it. + It reads in minifp.dtx and produces the files + minifp.sty and mfpextra.tex + minifp.pdf Documentation + test1.tex A suite of tests, including error messages (plain TeX) + test2.tex More tests, including long tests of speed (plain TeX) + README This file. + + This distribution, the latest updates, and possibly some past + versions, should also be available at my web site: + <http://comp.uark.edu/~luecking/tex/>. + +History: + + Version 0.9 : maximum possible accuracy achieved for angle, at some + cost to speed. + Version 0.8 : exp: now more accurate for many cases. + Version 0.7 : sqrt: now exact when possible and much more accurate. + Version 0.6 : Added angle to mfpextra. Changed package name to minifp. + Version 0.5 : Added sqrt, deg, rad to mfpextra. + Version 0.4 : Added log, exp, pow to mfpextra. + Version 0.3 : Added mfpextra.tex, defines sin and cos. + Version 0.2 : Added macros for printing, formatting the results. + Version 0.1 : First working set of macros. Package named mfp.sty. + +-- +Dan Luecking <luecking (at) uark (dot) edu> +Department of Mathematical Sciences +1 University of Arkansas +Fayetteville, Arkansas 72701-1201 +U.S.A. diff --git a/Master/texmf-dist/doc/generic/minifp/minifp.pdf b/Master/texmf-dist/doc/generic/minifp/minifp.pdf Binary files differnew file mode 100644 index 00000000000..94d43d6488f --- /dev/null +++ b/Master/texmf-dist/doc/generic/minifp/minifp.pdf diff --git a/Master/texmf-dist/doc/generic/minifp/test1.tex b/Master/texmf-dist/doc/generic/minifp/test1.tex new file mode 100644 index 00000000000..024e5c5a44d --- /dev/null +++ b/Master/texmf-dist/doc/generic/minifp/test1.tex @@ -0,0 +1,480 @@ +\errorcontextlines999\relax +%\def\MFPextra{} +X\input minifp.sty\relax X +X\MFPloadextra X + +\def\filbreak{\vskip 12pt plus 100pt\penalty 0 \vskip 0pt plus -100pt\relax} +\def\meaningless#1>{} +\def\verbprint#1{% +\begingroup + \toks0=\expandafter{#1}\edef\x{\the\toks0}% + \edef\x{\expandafter\meaningless\meaning\x}% + \tt "\x"% +\endgroup} +{\catcode`\@=11 + \gdef\y{\Y\\} + \gdef\Y{\space\verbprint\MFP@Rstack}% adds its own space +} +\def\\{\hfill\break\ignorespaces} +\def\U{\X} +\baselineskip 12.1pt plus .2pt minus 2pt + +\filbreak +\startMFPprogram +{\bf Stack-only operations:}\\ +Stack is empty, test the error message for popping an empty +stack:\immediate\write16{^^J*** The following tests the error for popping an +empty stack:^^J}\Rpop\X\y +Push 0.000 001:\Rpush{0.000 001}\y +Pop into {\tt\string\X}:\Rpop\X\\ +\indent {\tt \string\X:}\verbprint\X\\ +\indent {\tt stack:}\y +Push 1.2 then -2.3:\Rpush{1.2}\Rpush{-2.3}\y +Exchange them:\Rexch\y +Duplicate the last:\Rdup\Y + +\filbreak +{\bf Unary operations:}\\ +First a new stack with only one value +$21.34$:\Rpop\X\Rpop\X\Rpop\X\Rpush{21.34}\y +Unless otherwise noted, the stack will always be restored to this value +between operations. + +\medskip +\noindent +Change sign:\Rchs\y + \Rpop\X\Rpush{21.34}% +Absolute value:\Rabs\y + \Rpop\X\Rpush{21.34}% +Integer part:\Rint\y + \Rpop\X\Rpush{21.34}% +Fractional part:\Rfrac\y + \Rpop\X\Rpush{21.34}% +Double:\Rdbl\y + \Rpop\X\Rpush{21.34}% +Halve:\Rhalve\y + \Rpop\X\Rpush{21.34}% +Signum:\Rsgn\y + \Rpop\X\Rpush{-21.34}% +Signum of negative:\Rsgn\y + \Rpop\X\Rpush{21.34}% +Increment:\Rincr\y + \Rpop\X\Rpush{21.34}% +Decrement:\Rdecr\y + \Rpop\X\Rpush{21.34}% +Sine:\Rsin\y + \Rpop\X\Rpush{21.34}% +Cosine:\Rcos\y + \Rpop\X\Rpush{21.34}% +Radians to degrees:\Rdeg\y + \Rpop\X\Rpush{21.34}% +Degrees to radians :\Rrad\y + \Rpop\X\Rpush{21.34}% +Common logarithm:\Rlog\y + \Rpop\X\Rpush{21.34}% +Natural logarithm:\Rln\y +Put $-1.34$ on the stack:\Rpop\X\Rpush{-1.34}\y +Exponential:\Rexp\y +Put $3.3$ on the stack:\Rpop\X\Rpush{3.3}\y +Exponential:\Rexp\y +Back to $21.34$:\Rpop\X\Rpush{21.34}\y +Square:\Rsq\y + \Rpop\X\Rpush{21.34}% +\tracingmacros1 +Inversion:\Rinv\y +\tracingmacros0 + \Rpop\X\Rpush{21.34}% +Floor:\Rfloor\y + \Rpop\X\Rpush{21.34}% +Ceiling:\Rceil\y + \Rpop\X\Rpush{21.34}% +Square root:\Rsqrt\y +Now put $21.34$ and $12.34$ in that order:\Rpop\X\Rpush{21.34}\Rpush{12.34}\y +Compare: \Rcmp + 21.34 is\IFlt{}{ not} less than 12.34. + 21.34 is\IFgt{}{ not} more than 12.34. + 21.34 is\IFeq{}{ not} equal to 12.34.\\ +Take difference and check:\Rsub\Rchk\y + 21.34-12.34 is\IFneg {}{ not} negative. + 21.34-12.34 is\IFpos {}{ not} positive. + 21.34-12.34 is\IFzero{}{ not} zero. + +\Rpop\X + +\filbreak +{\bf Binary operations:}\\ +({\it After each operation we restore the original stack.})\\ +Start with empty stack and\\ +push 1.2 then -2.3:\Rpush{1.2}\Rpush{-2.3}\y +Angle:\Rangle\y\Rpop\X\Rpush{1.2}\Rpush{-2.3}% +Add:\Radd\y\Rpop\X\Rpush{1.2}\Rpush{-2.3}% +Subtract:\Rsub\y\Rpop\X\Rpush{1.2}\Rpush{-2.3}% +Multiply:\Rmul\y\Rpop\X\Rpush{1.2}\Rpush{-2.3}% +Divide:\Rdiv\y +New stack:\Rpop\X\Rpush{2.3}\Rpush{0}\y +\immediate\write16{^^J*** The following tests the error for dividing by 0:^^J} +Divide by zero:\Rdiv\y +Reset stack:\Rpop\X\Rpush{2.3}\Rpush{17}\y +Raise to a power ($(2.3)^{17}$):\Rpow\y +Reset stack:\Rpop\X\Rpush{2.3}\Rpush{-17}\y +Raise to a power ($(2.3)^{-17}$):\Rpow\y +Back to $1.2$ and $-2.3$:\Rpop\X\Rpush{1.2}\Rpush{-2.3}\y +Find max:\Rmax\y + \Rpop\X\Rpush{1.2}\Rpush{-2.3}% +Find min:\Rmin\y +Exporting stack (value above).\\ +Exporting \verbprint\U: \verbprint\X +\ExportStack +\Export\X +% change \X +\def\X{0} +\stopMFPprogram + +\medskip +\noindent +Exported value of \verbprint\U: \verbprint\X\\ +Exported value of stack:\Y + +\def\w{\W\\} +\def\W{ \verbprint\Z}% adds its own space + +\filbreak +{\bf Operand forms}\\ +{\it All results go to {\tt\string\Z}. All operate on {\tt\string\X} +and/or {\tt\string\Y}}\\ +Define ${\tt X}=1.2$ and ${\tt Y}=-2.3$:\def\X{1.2}\def\Y{-2.3}\\ +\indent {\tt X}:=\verbprint\X\\ +\indent {\tt Y}:=\verbprint\Y + +\filbreak +{\bf Unary operations:}\\ + Change sign of {\tt X}:\MFPchs\X\Z\w + Change sign of {\tt Y}:\MFPchs\Y\Z\w + Absolute value of {\tt X}:\MFPabs\X\Z\w + Absolute value of {\tt Y}:\MFPabs\Y\Z\w + Double value of {\tt X}:\MFPdbl\X\Z\w + Double value of {\tt Y}:\MFPdbl\Y\Z\w + Half of {\tt X}:\MFPhalve\X\Z\w + Half of {\tt Y}:\MFPhalve\Y\Z\w + Integer part of {\tt X}:\MFPint\X\Z\w + Integer part of {\tt Y}:\MFPint\Y\Z\w + Signum of {\tt X}:\MFPsgn\X\Z\w + Signum of {\tt Y}:\MFPsgn\Y\Z\w + Increment of {\tt X}:\MFPincr\X\Z\w + Increment of {\tt Y}:\MFPincr\Y\Z\w + Decrement of {\tt X}:\MFPdecr\X\Z\w + Decrement of {\tt Y}:\MFPdecr\Y\Z\w + Square of {\tt X}:\MFPsq\X\Z\w + Square of {\tt Y}:\MFPsq\Y\Z\w + Inverse of {\tt X}:\MFPinv\X\Z\w + Inverse of {\tt Y}:\MFPinv\Y\Z\w + Fractional part of {\tt X}:\MFPfrac\X\Z\w + Fractional part of {\tt Y}:\MFPfrac\Y\Z\w + Floor of {\tt X}:\MFPfloor\X\Z\w + Floor of {\tt Y}:\MFPfloor\Y\Z\w + Ceiling of {\tt X}:\MFPceil\X\Z\w + Ceiling of {\tt Y}:\MFPceil\Y\Z\w + Sine of {\tt 30}:\MFPsin{30}\Z\w + Sine of {\tt 420}:\MFPsin{420}\Z\w + Cosine of {\tt 60}:\MFPcos{60}\Z\w + Cosine of {\tt 390}:\MFPcos{390}\Z\w + Common logarithm of {\tt X}:\MFPlog\X\Z\w +\immediate\write16{^^J*** The following tests the warning for log of a negative +number:^^J}% + Common logarithm of {\tt Y}:\MFPlog\Y\Z\w +Natural logarithm of {\tt X}:\MFPln\X\Z\w +\immediate\write16{^^J*** The following tests the warning for ln of a negative +number:^^J}% +Natural Logarithm of {\tt Y}:\MFPln\Y\Z\w + Exponential of {\tt X}:\MFPexp\X\Z\w + Exponential of {\tt Y}:\MFPexp\Y\Z\W + +\filbreak +{\bf Extra tests of sine}\\ +Sine of 1:\MFPsin{1}\Z\w +Cosine of 1:\MFPcos{1}\Z\w +Sine of $-2$:\MFPsin{-2}\Z\w +Cosine of 3:\MFPcos{3}\Z\w +Sine of $-4$:\MFPsin{-4}\Z\w +Cosine of 5:\MFPcos{5}\Z\w +Sine of $-6$:\MFPsin{-6}\Z\w +Cosine of 7:\MFPcos{7}\Z\w +Sine of $-8$:\MFPsin{-8}\Z\w +Cosine of 9:\MFPcos{9}\Z\w +Sine of $-10$:\MFPsin{-10}\Z\w +Cosine of 20:\MFPcos{20}\Z\w +Sine of $-30$:\MFPsin{-30}\Z\w +Cosine of 40:\MFPcos{40}\Z\w +Sine of $-50$:\MFPsin{-50}\Z\w +Cosine of 60:\MFPcos{60}\Z\w +Sine of $-70$:\MFPsin{-70}\Z\w +Cosine of 80:\MFPcos{80}\Z\w +Sine of $-90$:\MFPsin{-90}\Z\w +Sine of $135$:\MFPsin{135}\Z\w +Sine of $180$:\MFPsin{180}\Z\w +Sine of $225$:\MFPsin{225}\Z\w +Sine of $270$:\MFPsin{270}\Z\w +Sine of $315$:\MFPsin{315}\Z\W + +\medskip +\noindent +Angle of $(10,.1)$:\MFPangle{10}{.1}\Z\w +Angle of $(-11.5,.1)$:\MFPangle{-11.5}{.1}\Z\w +Angle of $(11.5,-.2)$:\MFPangle{11.5}{-.2}\Z\w +Angle of $(-11.5,.3)$:\MFPangle{-11.5}{.3}\Z\w +Angle of $(11.5,-.4)$:\MFPangle{11.5}{-.4}\Z\w +Angle of $(-11.5,.5)$:\MFPangle{-11.5}{.5}\Z\w +Angle of $(11.5,-.6)$:\MFPangle{11.5}{-.6}\Z\w +Angle of $(-11.5,.7)$:\MFPangle{-11.5}{.7}\Z\w +Angle of $(11.5,-.8)$:\MFPangle{11.5}{-.8}\Z\w +Angle of $(-11.5,.9)$:\MFPangle{-11.5}{.9}\Z\w + Angle of $(11.5,-1)$:\MFPangle{11.5}{-1}\Z\w + Angle of $(-11.5,2)$:\MFPangle{-11.5}{2}\Z\w + Angle of $(11.5,-3)$:\MFPangle{11.5}{-3}\Z\w + Angle of $(-11.5,4)$:\MFPangle{-11.5}{4}\Z\w + Angle of $(11.5,-5)$:\MFPangle{11.5}{-5}\Z\w + Angle of $(-11.5,6)$:\MFPangle{-11.5}{6}\Z\w + Angle of $(11.5,-7)$:\MFPangle{11.5}{-7}\Z\w + Angle of $(-11.5,8)$:\MFPangle{-11.5}{8}\Z\w + Angle of $(11.5,-9)$:\MFPangle{11.5}{-9}\Z\w +Angle of $(-11.5,10)$:\MFPangle{-11.5}{10}\Z\w +Angle of $(11.5,-20)$:\MFPangle{11.5}{-20}\Z\w +Angle of $(-11.5,30)$:\MFPangle{-11.5}{30}\Z\w +Angle of $(11.5,-40)$:\MFPangle{11.5}{-40}\Z\w +Angle of $(-11.5,50)$:\MFPangle{-11.5}{50}\Z\w +Angle of $(11.5,-60)$:\MFPangle{11.5}{-60}\Z\w +Angle of $(-11.5,70)$:\MFPangle{-11.5}{70}\Z\w +Angle of $(11.5,-80)$:\MFPangle{11.5}{-80}\Z\w +Angle of $(-11.5,90)$:\MFPangle{-11.5}{90}\Z\w +Angle of $(11.5,-100)$:\MFPangle{11.5}{-100}\Z\w +Angle of $(0,10)$:\MFPangle{0}{10}\Z\w +Angle of $(0,-10)$:\MFPangle{0}{-10}\Z\w +\immediate\write16{^^J*** The following tests the warning for angle of +(0,0):^^J} +Angle of $(0,0)$:\MFPangle{0}{0}\Z\W + +\noindent +Testing large arguments:\\ +Angle of $(85 713 000, 99 999 999)$:\MFPangle{8571 3000}{9999 9999}\Z\W + + +\filbreak +{\bf Extra tests of log}\\ + Log of $.1$:\MFPlog{.1}\Z\w + Log of $.2$:\MFPlog{.2}\Z\w + Log of $.3$:\MFPlog{.3}\Z\w + Log of $.4$:\MFPlog{.4}\Z\w + Log of $.5$:\MFPlog{.5}\Z\w + Log of $.6$:\MFPlog{.6}\Z\w + Log of $.7$:\MFPlog{.7}\Z\w + Log of $.8$:\MFPlog{.8}\Z\w + Log of $.9$:\MFPlog{.9}\Z\w + Log of $1$:\MFPlog{1}\Z\w +Log of $1.01$:\MFPlog{1.01}\Z\w +Log of $1.02$:\MFPlog{1.02}\Z\w +Log of $1.03$:\MFPlog{1.03}\Z\w +Log of $1.04$:\MFPlog{1.04}\Z\w +Log of $1.05$:\MFPlog{1.05}\Z\w +Log of $1.06$:\MFPlog{1.06}\Z\w +Log of $1.07$:\MFPlog{1.07}\Z\w +Log of $1.08$:\MFPlog{1.08}\Z\w +Log of $1.09$:\MFPlog{1.09}\Z\w +\immediate\write16{^^J*** The following tests the error for log of 0:^^J} +Log of $0$:\MFPlog{0}\Z\W + +\filbreak +{\bf Extra tests of exp}\\ + Exp of $.00009990$:\MFPexp{.00009990}\Z +\w + Exp of $.00009999$:\MFPexp{.00009999}\Z\w + Exp of $.0001$:\MFPexp{.0001}\Z\w + Exp of $.0002$:\MFPexp{.0002}\Z\w + Exp of $.0003$:\MFPexp{.0003}\Z\w + Exp of $.0004$:\MFPexp{.0004}\Z\w + Exp of $.0005$:\MFPexp{.0005}\Z\w + Exp of $.0006$:\MFPexp{.0006}\Z\w + Exp of $.0007$:\MFPexp{.0007}\Z\w + Exp of $.0008$:\MFPexp{.0008}\Z\w + Exp of $.0009$:\MFPexp{.0009}\Z\w + Exp of $.001$:\MFPexp{.001}\Z\w + Exp of $.002$:\MFPexp{.002}\Z\w + Exp of $.003$:\MFPexp{.003}\Z\w + Exp of $.004$:\MFPexp{.004}\Z\w + Exp of $.005$:\MFPexp{.005}\Z\w + Exp of $.006$:\MFPexp{.006}\Z\w + Exp of $.007$:\MFPexp{.007}\Z\w + Exp of $.008$:\MFPexp{.008}\Z\w + Exp of $.009$:\MFPexp{.009}\Z\w + Exp of $.01$:\MFPexp{.01}\Z\w + Exp of $.02$:\MFPexp{.02}\Z\w + Exp of $.03$:\MFPexp{.03}\Z\w + Exp of $.04$:\MFPexp{.04}\Z\w + Exp of $.05$:\MFPexp{.05}\Z\w + Exp of $.06$:\MFPexp{.06}\Z\w + Exp of $.07$:\MFPexp{.07}\Z\w + Exp of $.08$:\MFPexp{.08}\Z\w + Exp of $.09$:\MFPexp{.09}\Z\w + Exp of $.1$:\MFPexp{.1}\Z\w + Exp of $.2$:\MFPexp{.2}\Z\w + Exp of $.3$:\MFPexp{.3}\Z\w + Exp of $.4$:\MFPexp{.4}\Z\w + Exp of $.5$:\MFPexp{.5}\Z\w + Exp of $.6$:\MFPexp{.6}\Z\w + Exp of $.7$:\MFPexp{.7}\Z\w + Exp of $.8$:\MFPexp{.8}\Z\w + Exp of $.9$:\MFPexp{.9}\Z\w + Exp of $1$:\MFPexp{1}\Z\w + Exp of $2$:\MFPexp{2}\Z\w + Exp of $3$:\MFPexp{3}\Z\w + Exp of $4$:\MFPexp{4}\Z\w + Exp of $5$:\MFPexp{5}\Z\w + Exp of $6$:\MFPexp{6}\Z\w + Exp of $7$:\MFPexp{7}\Z\w + Exp of $8$:\MFPexp{8}\Z\w + Exp of $9$:\MFPexp{9}\Z\w + Exp of $10$:\MFPexp{10}\Z\w + Exp of $-8.3254$:\MFPexp{-8.3254}\Z\w + Exp of $18.42068073$:\MFPexp{18.42068073}\Z\w + Exp of $18.42068074$:\MFPexp{18.42068074}\Z\w +\immediate\write16{^^J*** The following tests the error for a power too +large:^^J} + Exp of $18.42068075$:\MFPexp{18.42068075}\Z\W + +\filbreak +{\bf Extra tests of pow}\\ + $-10$ power of $3$:\MFPpow{3}{-10}\Z\w + $-9$ power of $3$:\MFPpow{3}{-9}\Z\w + $-8$ power of $3$:\MFPpow{3}{-8}\Z\w + $-7$ power of $3$:\MFPpow{3}{-7}\Z\w + $-6$ power of $3$:\MFPpow{3}{-6}\Z\w + $-5$ power of $3$:\MFPpow{3}{-5}\Z\w + $-4$ power of $3$:\MFPpow{3}{-4}\Z\w + $-3$ power of $3$:\MFPpow{3}{-3}\Z\w + $-2$ power of $3$:\MFPpow{3}{-2}\Z\w + $-1$ power of $3$:\MFPpow{3}{-1}\Z\w + $0$ power of $3$:\MFPpow{3}{0}\Z\w + $1$ power of $3$:\MFPpow{3}{1}\Z\w + $2$ power of $3$:\MFPpow{3}{2}\Z\w + $3$ power of $3$:\MFPpow{3}{3}\Z\w + $4$ power of $3$:\MFPpow{3}{4}\Z\w + $5$ power of $3$:\MFPpow{3}{5}\Z\w + $6$ power of $3$:\MFPpow{3}{6}\Z\w + $7$ power of $3$:\MFPpow{3}{7}\Z\w + $8$ power of $3$:\MFPpow{3}{8}\Z\w + $9$ power of $3$:\MFPpow{3}{9}\Z\w + $10$ power of $3$:\MFPpow{3}{10}\Z\w +\immediate\write16{^^J*** The following tests the error for a power too +large:^^J} + $10$ power of $9$:\MFPpow{9}{10}\Z\w +\immediate\write16{^^J*** The following also tests the error for a power too +large:^^J} + $10$ power of $-9$:\MFPpow{-9}{10}\Z\w +\immediate\write16{^^J*** The following also tests the error for a power too +large:^^J} + $11$ power of $-9$:\MFPpow{-9}{11}\Z\w +\immediate\write16{^^J*** The following tests the error for a negative power of +0:^^J} + $-10$ power of $0$:\MFPpow{0}{-10}\Z\w +\immediate\write16{^^J*** The following also tests the error for a power too +large:^^J} + $-10$ power of $0.1$:\MFPpow{0.1}{-10}\Z\W + +\filbreak +{\bf Extra tests of sqrt}\\ +\immediate\write16{^^J*** The following tests the error for a square root of a +negative:^^J} + Square root of $-1$:\MFPsqrt{-1}\Z\w + Square root of $0$:\MFPsqrt{0}\Z\w + Square root of $.0001$:\MFPsqrt{.0001}\Z\w + Square root of $.002$:\MFPsqrt{.002}\Z\w + Square root of $.03$:\MFPsqrt{.03}\Z\w + Square root of $.4$:\MFPsqrt{.4}\Z\w + Square root of $.5$:\MFPsqrt{.5}\Z\w + Square root of $.6$:\MFPsqrt{.6}\Z\w + Square root of $.7$:\MFPsqrt{.7}\Z\w + Square root of $.8$:\MFPsqrt{.8}\Z\w + Square root of $.9$:\MFPsqrt{.9}\Z\w + Square root of $1$:\MFPsqrt{1}\Z\w + Square root of $2$:\MFPsqrt{2}\Z\w + Square root of $3$:\MFPsqrt{3}\Z\w + Square root of $4$:\MFPsqrt{4}\Z\w + Square root of $5$:\MFPsqrt{5}\Z\w + Square root of $6$:\MFPsqrt{6}\Z\w + Square root of $7$:\MFPsqrt{7}\Z\w + Square root of $8$:\MFPsqrt{8}\Z\w + Square root of $9$:\MFPsqrt{9}\Z\w + Square root of $10$:\MFPsqrt{10}\Z\w + Square root of $1524157.65279684$ (should be exact):\MFPsqrt{1524157.65279684}\Z\w +Square root of $99999998.00000001$ (should be exact):\MFPsqrt{99999998.00000001}\Z\w + Square root of $9999.99$:\MFPsqrt{9999.99}\Z\w + Square root of $9999.999 999$:\MFPsqrt{9999.999999}\Z\W + +\filbreak +{\bf Binary operations:}\\ +Add $X+Y$:\MFPadd\X\Y\Z\w +Add $\infty+\infty$:\MFPadd{99999999.99999999}{99999999.99999999}\Z\w +Subtract $X-Y$:\MFPsub\X\Y\Z\w +Subtract $Y-X$:\MFPsub\Y\X\Z\w +Subtract $X-X$:\MFPsub\X\X\Z\w +Subtract $Y-Y$:\MFPsub\Y\Y\Z\w +Multiply:\MFPmul\X\Y\Z\w +Multiply $10^4\times10^4$:\MFPmul{10000}{10000}\Z\w +Divide $X/Y$:\MFPdiv\X\Y\Z\w +Divide $Y/X$:\MFPdiv\Y\X\Z\w +Max:\MFPmax\X\Y\Z\w +Min:\MFPmin\X\Y\Z\w +Angle $(X,Y)$:\MFPangle\X\Y\Z\w +Angle $(Y,X)$:\MFPangle\Y\X\Z\w +Power $X^5$:\MFPpow\X{5}\Z\w +Power $X^{-5}$:\MFPpow\X{-5}\Z\w +Power $Y^{5}$:\MFPpow\Y{5}\Z\w +Power $Y^{-5}$:\MFPpow\Y{-5}\Z\w +Compare: \MFPcmp\X\Y + \X\ is\IFlt{}{ not} less than \Y. + \X\ is\IFgt{}{ not} more than \Y. + \X\ is\IFeq{}{ not} equal to \Y.\\ +Take difference and check:\MFPsub\X\Y\Z\w + $\X-\Y$ is\IFneg{}{ not} negative. + $\X-\Y$ is\IFpos{}{ not} positive. + $\X-\Y$ is\IFzero{}{ not} zero. + +\filbreak +{\bf Print-related formating} + +\def\T{333.00000000} +\def\S{1357.12345678} + +\noindent This is original: $T ={}${\tt"\T"}\\ +Truncate to 4 digits right of decimal:\MFPtruncate{4}\T\Z\w +Truncate to the decimal:\MFPtruncate{0}\T\Z\w +Truncate to 2 digits left of decimal:\MFPtruncate{-2}\T\Z\w +Strip trailing zeros:\MFPstrip\T\Z\w +Strip trailing zeros (star form):\MFPstrip*\T\Z\W + +\noindent Original: $S = {}${\tt"\S"}\\ +Round to 3 decimals:\MFPround{3}\S\Z\w +Round to 5 decimals:\MFPround{5}\S\Z\w +Round to 0 decimals:\MFPround{0}\S\Z\w +Round to 100s:\MFPround{-2}\S\Z\W + +\def\T{-333.00000000} +\def\S{-1357.12345678} + +\filbreak +\noindent All that again with negative numbers. + +\medskip +\noindent This is original: $T ={}${\tt"\T"}\\ +Truncate to 4 digits right of decimal:\MFPtruncate{4}\T\Z\w +Truncate to the decimal:\MFPtruncate{0}\T\Z\w +Truncate to 2 digits left of decimal:\MFPtruncate{-2}\T\Z\w +Strip trailing zeros:\MFPstrip\T\Z\w +Strip trailing zeros (star form):\MFPstrip*\T\Z\W + +\noindent Original: $S = {}${\tt"\S"}\\ +Round to 3 decimals:\MFPround{3}\S\Z\w +Round to 5 decimals:\MFPround{5}\S\Z\w +Round to 0 decimals:\MFPround{0}\S\Z\w +Round to 100s:\MFPround{-2}\S\Z\W + +\end{document} diff --git a/Master/texmf-dist/doc/generic/minifp/test2.tex b/Master/texmf-dist/doc/generic/minifp/test2.tex new file mode 100644 index 00000000000..8cd7ab278c5 --- /dev/null +++ b/Master/texmf-dist/doc/generic/minifp/test2.tex @@ -0,0 +1,376 @@ +\errorcontextlines999\relax +X\input minifp.sty\relax X\MFPloadextra X +\def\empty{} + +\def\frac#1#2{{#1\over#2}} +\def\cs#1{{\tt \char`\\#1}} +\def\mybreak{\vskip 0pt plus 100pt\penalty 0 \vskip 0pt plus -100pt\relax} +\def\\{\hfil\break\ignorespaces} +\def\y{Rpop\Z\Z\\} +\def\Y{Rpop\Z\Z} +\everymath{\displaystyle} + +{\bf Stack-only operations:}\\ +Example of a program. Computes the solution of $ax^2 + bx + c = 0$ using +the quadratic formula. If the result is complex, it detects this. +Coefficients stored in \cs{A}, \cs{B} and \cs{C}. First case: $4x^2 + +5y^2 - 1= 0$. Solutions are $x = -\frac{5}{8} \pm \frac{1}{8}\sqrt{41}$ + +\def\A{4}\def\B{5}\def\C{-1} + +X\startMFPprogram % stack +\Rpush\B\Rdup\Rsq % B(B^2) +\Rpush\A\Rpush\C\Rmul\Rdbl\Rdbl % B(B^2)(4AC) +\Rsub % B(B^2-4AC) +\IFneg{\def\I{i}\Rchs}{\def\I{}}% % B(|B^2-4AC|) +\Rsqrt\Rpush\A\Rdbl\Rdiv % B(sqrt(|B^2-4AC|)/2A) +\Rpop\Ypart % B +\Rpush\A\Rdbl\Rdiv\Rchs % (-B/2A) +\Rpop\Xpart % +%\expandafter\show\csname MFP@Rstack\endcsname +\Rpush\Xpart\Rpush\Ypart\Radd\Rpop\Broot +\Rpush\Xpart\Rpush\Ypart\Rsub\Rpop\Sroot +\Export\Xpart +\Export\Ypart +\Export\Broot +\Export\Sroot +\Export\I +\stopMFPprogram X + +\indent Solution: $x = \Xpart \pm \I\Ypart = \Broot$ and $\Sroot$. + +Second case $2x^2 - 2x + 3 = 0$. Solutions are $x = \frac{1}{2} \pm +\frac{i}{2}\sqrt{5}$. + +\def\A{2}\def\B{-2}\def\C{3} + +X\startMFPprogram % stack +\Rpush\B\Rdup\Rsq % B(B^2) +\Rpush\A\Rpush\C\Rmul\Rdbl\Rdbl % B(B^2)(4AC) +\Rsub % B(B^2-4AC) +\IFneg{\def\I{i}\Rchs}{\def\I{}}% % B(|B^2-4AC|) +\Rsqrt\Rpush\A\Rdbl\Rdiv % B(sqrt(|B^2-4AC|)/2A) +\Rpop\Ypart % B +\Rpush\A\Rdbl\Rdiv\Rchs % (-B/2A) +\Rpop\Xpart % +\Export\Xpart +\Export\Ypart +\Export\I +\stopMFPprogram X + +%\expandafter\show\csname MFP@Rstack\endcsname +\indent Solution: $x = \Xpart \pm \I\Ypart$. + +Now try square roots (should be exactly 1234.5678 and 1524): +X\startMFPprogram % stack +\Rpush{1524157.65279684}\Rsqrt\Rpop\X +\Rpush{1524}\Rsq\Rsqrt\Rpop\Y +\Export\X +\Export\Y +\stopMFPprogram X \X { and }\Y. + + +Below we test for speed and to check for any space characters +accidentally produced. You should see only a few xX pairs with hopefully +no spaces in between them. As curently set up, these tests perform about +34000 numerical operations. It all takes about 31 seconds on a +moderately old (2 years?) Windows 7 running plain tex from +TeX~Live~2012. + +This operation count does not distinguish between basic operations like +addition and multiplication, and those operations from mfpextra that are +probably each equivalent to a dozen or more multiplications. Counting +each such operation with the an estimated multiplicity, the tests +probably perform 400 thousand or more basic operations. + +Of the basic operations, multiplication is (by measurement) 4 times as +lengthy as addition, and division is about twice as lengthy as +multiplication. Actual times depend on the machine, but the ratios remain +pretty much the same. Here is a summary of timings on my fastest +machine; each operation is run 500 times in a loop: + +\medskip + +\indent\vtop{\halign{\hfil$#$&\quad$#\,$sec\cr +\noalign{\hrule\smallskip} +2.54321+22432.87654321 &0.015\cr +2.54321\times22432.87654321 &0.06\cr +22432.87654321/2.54321 &0.14\cr +\sqrt{23456789.54321} &0.20\cr +1.00001234^{8000} &0.73\cr +\exp(2.54321) &0.41\cr +\sin(2.54321) &0.45\cr +\log(2.54321) &0.53\cr +\mathop{\fam0 angle}(254.321,100) &1.17\cr +\noalign{\smallskip\hrule} +}} + +\medskip + +Originally, all the tests combined took 21 seconds on a 4-year-old +Windows XP under TeX Live 2011. But since then I have changed angle and +power computations so that they are considerably more accurate, but with +a possible reduction in speed. Of course, some of the speed loss may be +due to the operating system. + +On a Windows 7 machine, 64-bit, laptop, it takes 32 seconds to process +this file. On another Win7, machine, 32-bit, desktop, it takes 10 +seconds. + +The difference could be explained partially by the fact that the second +machine is newer and partially by the fact that TeX is a 32-bit program, +and therefore a better match to the operating system of the second +system. + +\def\testi{% stack forms +\startMFPprogram +\Rpush{0.000 001}\Rpop\X +\Rpush{1.2}\Rpush{-2.3}\Rexch\Rdup +\Rpop\X\Rpop\X +\Rpop\X\Rpush{21.34}\Rchs +\Rpop\X\Rpush{21.34}\Rabs +\Rpop\X\Rpush{21.34}\Rchs +\Rpop\X\Rpush{21.34}\Rint +\Rpop\X\Rpush{21.34}\Rfrac +\Rpop\X\Rpush{21.34}\Rdbl +\Rpop\X\Rpush{21.34}\Rhalve +\Rpop\X\Rpush{21.34}\Rsgn +\Rpop\X\Rpush{21.34}\Rsin +\Rpop\X\Rpush{21.34}\Rcos +\Rpop\X\Rpush{21.34}\Rdeg +\Rpop\X\Rpush{21.34}\Rrad +\Rpop\X\Rpush{21.34}\Rlog +\Rpop\X\Rpush{21.34}\Rln +\Rpop\X\Rpush{-1.34}\Rexp +\Rpop\X\Rpush{3.3}\Rexp +\Rpop\X\Rpush{21.34}\Rsq +\Rpop\X\Rpush{21.34}\Rinv +\Rpop\X\Rpush{21.34}\Rfloor +\Rpop\X\Rpush{21.34}\Rceil +\Rpop\X\Rpush{21.34}\Rsqrt +\Rpop\X\Rpush{21.34}\Rpush{12.34}\Rcmp +\IFlt{}{}\IFgt{}{}\IFeq{}{}\Rsub +\IFneg{}{}\IFpos{}{}\IFzero{}{}\Rpop\X +\Rpush{1.2}\Rpush{-2.3}\Radd +\Rpop\X\Rpush{1.2}\Rpush{-2.3}\Rsub +\Rpop\X\Rpush{1.2}\Rpush{-2.3}\Rmul +\Rpop\X\Rpush{1.2}\Rpush{-2.3}\Rdiv +\Rpop\X\Rpush{2.3}\Rpush{17}\Rpow +\Rpop\X\Rpush{2.3}\Rpush{-17}\Rpow +\Rpop\X\Rpush{1.2}\Rpush{-2.3}\Rmax +\Rpop\X\Rpush{1.2}\Rpush{-2.3}\Rmin +\stopMFPprogram} + +\def\testii{% unary operand forms, including +\MFPchs\X\Z % extra tests of sin, log, exp and pow +\MFPchs\Y\Z +\MFPabs\X\Z +\MFPabs\Y\Z +\MFPdbl\X\Z +\MFPdbl\Y\Z +\MFPhalve\X\Z +\MFPhalve\Y\Z +\MFPint\X\Z +\MFPint\Y\Z +\MFPsgn\X\Z +\MFPsgn\Y\Z +\MFPsq\X\Z +\MFPsq\Y\Z +\MFPinv\X\Z +\MFPinv\Y\Z +\MFPfrac\X\Z +\MFPfrac\Y\Z +\MFPfloor\X\Z +\MFPfloor\Y\Z +\MFPceil\X\Z +\MFPceil\Y\Z +\MFPsin{30}\Z +\MFPsin{420}\Z +\MFPcos{60}\Z +\MFPcos{390}\Z +\MFPlog\X\Z +\MFPln\X\Z +\MFPexp\X\Z +\MFPexp\Y\Z +\MFPsin{1}\Z +\MFPsin{2}\Z +\MFPsin{3}\Z +\MFPsin{4}\Z +\MFPsin{5}\Z +\MFPsin{6}\Z +\MFPsin{7}\Z +\MFPsin{8}\Z +\MFPsin{9}\Z +\MFPsin{10}\Z +\MFPsin{20}\Z +\MFPsin{30}\Z +\MFPsin{40}\Z +\MFPsin{50}\Z +\MFPsin{60}\Z +\MFPsin{70}\Z +\MFPsin{80}\Z +\MFPsin{90}\Z +\MFPlog{.1}\Z +\MFPlog{.2}\Z +\MFPlog{.3}\Z +\MFPlog{.4}\Z +\MFPlog{.5}\Z +\MFPlog{.6}\Z +\MFPlog{.7}\Z +\MFPlog{.8}\Z +\MFPlog{.9}\Z +\MFPlog{1}\Z +\MFPlog{1.01}\Z +\MFPlog{1.02}\Z +\MFPlog{1.03}\Z +\MFPlog{1.04}\Z +\MFPlog{1.05}\Z +\MFPlog{1.06}\Z +\MFPlog{1.07}\Z +\MFPlog{1.08}\Z +\MFPlog{1.09}\Z +\MFPexp{.000001}\Z +\MFPexp{.00001}\Z +\MFPexp{.0001}\Z +\MFPexp{.001}\Z +\MFPexp{.01}\Z +\MFPexp{.1}\Z +\MFPexp{1}\Z +\MFPexp{2}\Z +\MFPexp{3}\Z +\MFPexp{4}\Z +\MFPexp{5}\Z +\MFPexp{6}\Z +\MFPexp{7}\Z +\MFPexp{8}\Z +\MFPexp{9}\Z +\MFPexp{10}\Z +\MFPexp{-8.3254}\Z +\MFPpow\MFPe{-10}\Z +\MFPpow\MFPe{-9}\Z +\MFPpow\MFPe{-8}\Z +\MFPpow\MFPe{-7}\Z +\MFPpow\MFPe{-6}\Z +\MFPpow\MFPe{-5}\Z +\MFPpow\MFPe{-4}\Z +\MFPpow\MFPe{-3}\Z +\MFPpow\MFPe{-2}\Z +\MFPpow\MFPe{-1}\Z +\MFPpow\MFPe{0}\Z +\MFPpow\MFPe{1}\Z +\MFPpow\MFPe{2}\Z +\MFPpow\MFPe{3}\Z +\MFPpow\MFPe{4}\Z +\MFPpow\MFPe{5}\Z +\MFPpow\MFPe{6}\Z +\MFPpow\MFPe{7}\Z +\MFPpow\MFPe{8}\Z +\MFPpow\MFPe{9}\Z +\MFPpow\MFPe{10}\Z} + +\def\testiii{%% binary operand forms and print formating, plus +\MFPsqrt{0}\Z % additional tests of sqrt +\MFPsqrt{1}\Z +\MFPsqrt{2}\Z +\MFPsqrt{3}\Z +\MFPsqrt{4}\Z +\MFPsqrt{5}\Z +\MFPsqrt{6}\Z +\MFPsqrt{7}\Z +\MFPsqrt{8}\Z +\MFPsqrt{9}\Z +\MFPsqrt{10}\Z +\MFPsqrt{1524157.65279684}\Z +\MFPadd\X\Y\Z +\MFPsub\X\Y\Z +\MFPsub\Y\X\Z +\MFPsub\X\X\Z +\MFPsub\Y\Y\Z +\MFPmul\X\Y\Z +\MFPdiv\X\Y\Z +\MFPdiv\Y\X\Z +\MFPmax\X\Y\Z +\MFPmin\X\Y\Z +\MFPpow\X{5}\Z +\MFPpow\X{-5}\Z +\MFPpow\Y{5}\Z +\MFPpow\Y{-5}\Z +\MFPcmp\X\Y +\IFlt{}{}\IFgt{}{}\IFeq{}{}% +\MFPsub\X\Y\Z +\IFneg{}{}\IFpos{}{}\IFzero{}{}% +\def\T{333.00000000}% +\def\S{1357.12345678}% +\MFPtruncate{4}\T\Z +\MFPtruncate{0}\T\Z +\MFPtruncate{-2}\T\Z +\MFPstrip\T\Z +\MFPstrip*\T\Z +\MFPround{3}\S\Z +\MFPround{5}\S\Z +\MFPround{0}\S\Z +\MFPround{-2}\S\Z +\def\T{-333.00000000}% +\def\S{-1357.12345678}% +\MFPtruncate{4}\T\Z +\MFPtruncate{0}\T\Z +\MFPtruncate{-2}\T\Z +\MFPstrip\T\Z +\MFPstrip*\T\Z +\MFPround{3}\S\Z +\MFPround{5}\S\Z +\MFPround{0}\S\Z +\MFPround{-2}\S\Z} + +Three test loops follow. The first repeats 500 times a stack program +that performs each available command followed by popping the result and +repushing the original value(s). + +\newcount\n +\def\testloopi{% + \ifnum \n>0 + \advance\n -1 + \testi + \expandafter + \testloopi + \fi +} +\n=500 +x\testloopi X + + +The second repeats 100 times a sequence in which all the unary operand +commands are performed twice, plus extra of sine, log and exp. + +\def\testloopii{% + \ifnum \n>0 + \advance\n -1 + \testii + \expandafter + \testloopii + \fi +} +\def\X{1.2} +\def\Y{-2.3} +\n=100 +x\testloopii X + + +The third repeats 100 times a sequence in which all the binary operand +commands are performed, plus some extra tests of sqrt and then all the +print-preparation commands. + +\def\testloopiii{% + \ifnum \n>0 + \advance\n -1 + \testiii + \expandafter + \testloopiii + \fi +} + +\n=100 +x\testloopiii X +\end + +\end{document} |