From f00a20fdf325ef2fed5aad83f6105739b55d5373 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 1 Nov 2021 20:35:16 +0000 Subject: xintsession (1nov21) git-svn-id: svn://tug.org/texlive/trunk@60926 c570f23f-e606-0410-a88d-b1316a301751 --- .../tex/plain/xintsession/xintsession.tex | 132 +++++++++++++++++++-- 1 file changed, 120 insertions(+), 12 deletions(-) (limited to 'Master/texmf-dist/tex/plain') diff --git a/Master/texmf-dist/tex/plain/xintsession/xintsession.tex b/Master/texmf-dist/tex/plain/xintsession/xintsession.tex index d98af4f499e..f7aec508939 100644 --- a/Master/texmf-dist/tex/plain/xintsession/xintsession.tex +++ b/Master/texmf-dist/tex/plain/xintsession/xintsession.tex @@ -1,4 +1,4 @@ -% Release 0.3b (2021-07-01) of xintsession.tex +% Release 0.4alpha (2021-11-01) of xintsession.tex % author: Jean-Francois Burnol % License: LPPL 1.3c (author-maintained) % Usage: execute "etex (or pdftex) xintsession" @@ -55,7 +55,7 @@ _ / _ / / / /_ / __/ / / /_/ // /__ / /_ _ / __ |/ // __/__ /_/ /_/ /_/\__/ \___//_/ \__,_/ \___/ \__/ /_/ _____/ \___//_/% }% ?xdef?xs_copyright{% - xintsession 0.3a (2021-06-08) + xintsession 0.4alpha (2021-11-01) Copyright (c) Jean-Francois Burnol, 2021.% }}% \def\xs_no{0}% @@ -170,6 +170,7 @@ _ / _ / / / /_ / __/ / / /_/ // /__ / /_ _ / __ |/ // __/__ \edef\xs_funcname{\expandafter\xint_zapspaces\detokenize{#1} \xint_gobble_i}% \xint_gob_til_sc#2\xs_defvar;\xs_deffunc }% +\edef\xs_fourspaces{\space\space\space\space}% \def\xs_deffunc #1;% {% % attention: \xs_xintdeffunc needs to see parentheses immediately @@ -179,8 +180,16 @@ _ / _ / / / /_ / __/ / / /_/ // /__ / /_ _ / __ |/ // __/__ \detokenize\expandafter{\xs_right};}% \expandafter\ifx\xs_xintdeffunc\poldef \xs_message{\xs_funcname\space = \PolToExpr{\xs_funcname}}% - \xs_message{Issue \string\PolGenFloatVariant{\xs_funcname} if fp evaluations - with \xs_funcname\space are intended}% + \xs_message{\xs_fourspaces --> + &GenFloat(\xs_funcname) lets + \xs_funcname\space become usable as function in fp mode}% + \xs_message{\xs_fourspaces + --> &ROOTS(\xs_funcname) (resp. &ROOTS(\xs_funcname,N)) + finds all rational roots exactly and}% + \xs_message{\xs_fourspaces\xs_fourspaces + all irrational roots with at least + \xintsessiondefaultrootsprecision\space(resp. N) + fractional digits}% \else\xs_message{Function \xs_funcname\space defined}% \fi\xs_fetch }% @@ -247,6 +256,106 @@ _ / _ / / / /_ / __/ / / /_/ // /__ / /_ _ / __ |/ // __/__ \def\xs_xinteval{\xinteval}% }% \def\xs_magic@&mod{\xs_message{current mode: \xs_mode}}% +\def\xs_getpolname#1(#2#3)#4\xint_bye{\edef\xs_polname{\xint_zapspaces #2#3 \xint_gobble_i}}% +\def\xs_magic@&Gen +{% + \expandafter\xs_getpolname\xs_magic_inb\xint_bye + \PolGenFloatVariant{\xs_polname}% + \immediate\write\xs_out{\string\PolGenFloatVariant{\xs_polname}}% + \xs_message{Polynomial function \xs_polname\space for &fp mode usage now defined}% +}% +\def\xintsessiondefaultrootsprecision{10}% +\def\xs_getpolandE#1(#2#3)#4\xint_bye +{% + \xs_getpolandE_i#2#3,,\xint_bye +}% +\def\xs_getpolandE_i#1,#2,#3\xint_bye +{% + \edef\xs_polname{\xint_zapspaces #1 \xint_gobble_i}% + \edef\xs_rootsprecision{\if\relax#3\relax + \xintsessiondefaultrootsprecision\else + \xint_zapspaces #2 \xint_gobble_i\fi}% +}% +\expandafter\def\csname xs_magic@&ROO\endcsname +{% + \expandafter\xs_getpolandE\xs_magic_inb\xint_bye + \xs_message{Solving for real roots of \xs_polname\space and assigning them (please wait...)}% + \PolToSturm{\xs_polname}{@\xs_polname}% + \PolSturmIsolateZerosGetMultiplicitiesAndRationalRoots{@\xs_polname}% + \PolEnsureIntervalLengths{@\xs_polname}{-\xs_rootsprecision}% + \immediate\write\xs_out{\string\PolToSturm{\xs_polname}{@\xs_polname}}% + \immediate\write\xs_out{\string\PolSturmIsolateZerosGetMultiplicitiesAndRationalRoots{@\xs_polname}}% + \immediate\write\xs_out{\string\PolEnsureIntervalLengths{@\xs_polname}{-\xs_rootsprecision}}% + \immediate\write\xs_out{\string\PolPrintIntervals{@\xs_polname}}% + \xs_polprintintervals + \xs_message{Square-free irrational part: \PolToExpr{@\xs_polname _sqf_norr}}% + \ifnum\PolSturmNbOfIsolatedZeros{@\xs_polname}>\PolSturmNbOfRationalRoots{@\xs_polname} + \xs_message{\xs_fourspaces --> + &REFINEROOTS(\xs_polname,N) to extend real irr. roots to N fractional digits}% + \else + \xs_message{No irrational real roots.}% + \fi +}% +\expandafter\def\csname xs_magic@&REF\endcsname +{% + \expandafter\xs_getpolandE\xs_magic_inb\xint_bye + \xs_message{Refining real roots of \xs_polname\space to \xs_rootsprecision\space + digits (please wait...)}% + \PolEnsureIntervalLengths{@\xs_polname}{-\xs_rootsprecision}% + \immediate\write\xs_out{\string\PolEnsureIntervalLengths{@\xs_polname}{-\xs_rootsprecision}}% + \immediate\write\xs_out{\string\PolPrintIntervals{@\xs_polname}}% + \xs_polprintintervals +}% +\def\xs_polprintintervals +{% + \begingroup\xintglobaldefstrue + \def\PolPrintIntervalsNoRealRoots{\xs_message{No real roots.}}% + \let\PolPrintIntervalsBeginEnv\empty + \let\PolPrintIntervalsEndEnv\empty + \def\PolPrintIntervalsKnownRoot{\PolPrintIntervalsPrintExactZero}% + \def\PolPrintIntervalsUnknownRoot{\xintifSgn{\PolPrintIntervalsTheLeftEndPoint}% + {\PolPrintIntervalsPrintRightEndPoint}% + {\PolPrintIntervalsPrintLeftEndPoint}% + {\PolPrintIntervalsPrintLeftEndPoint}% + }% + \def\PolPrintIntervalsPrintExactZero + {\xs_message{(mult. \PolPrintIntervalsTheMultiplicity) + Root\xs_polname _\PolPrintIntervalsTheIndex\space = \PolPrintIntervalsTheLeftEndPoint}% + \immediate\write\xs_out{\string\xintdefvar\space + Root\xs_polname _\PolPrintIntervalsTheIndex:=\PolPrintIntervalsTheLeftEndPoint;}% + \XINT_expr_defvar_one{Root\xs_polname _\PolPrintIntervalsTheIndex}% + {{\xintRaw{\PolPrintIntervalsTheLeftEndPoint}}}% + }% + \def\PolPrintIntervalsPrintLeftEndPoint + {\xs_message{(mult. \PolPrintIntervalsTheMultiplicity) + Root\xs_polname _\PolPrintIntervalsTheIndex\space = \PolPrintIntervalsTheLeftEndPoint...}% + \immediate\write\xs_out{\string\xintdefvar\space + Root\xs_polname _\PolPrintIntervalsTheIndex:=\PolPrintIntervalsTheLeftEndPoint;}% + \XINT_expr_defvar_one{Root\xs_polname _\PolPrintIntervalsTheIndex}% + {{\xintRaw{\PolPrintIntervalsTheLeftEndPoint}}}% + }% + \def\PolPrintIntervalsPrintRightEndPoint + {\xs_message{(mult. \PolPrintIntervalsTheMultiplicity) + Root\xs_polname _\PolPrintIntervalsTheIndex\space = \PolPrintIntervalsTheRightEndPoint...}% + \immediate\write\xs_out{\string\xintdefvar\space + Root\xs_polname _\PolPrintIntervalsTheIndex:=\PolPrintIntervalsTheRightEndPoint;}% + \XINT_expr_defvar_one{Root\xs_polname _\PolPrintIntervalsTheIndex}% + {{\xintRaw{\PolPrintIntervalsTheRightEndPoint}}}% + }% + \def\POL@PrintIntervals@Loop{% + \POL@SturmIfZeroExactlyKnown\PolPrintIntervalsTheSturmName\PolPrintIntervalsTheIndex + \PolPrintIntervalsKnownRoot + \PolPrintIntervalsUnknownRoot + \xdef\PolPrintIntervalsTheIndex{\the\numexpr\PolPrintIntervalsTheIndex+\@ne}% + \unless\ifnum\PolPrintIntervalsTheIndex> + \@nameuse{POL_ZL\PolPrintIntervalsTheSturmName*0} + \POL@PrintIntervals@DoDefs + \expandafter\POL@PrintIntervals@Loop + \fi + }% + \PolPrintIntervals{@\xs_polname}% + \endgroup +}% \def\xs_setenv {% \newlinechar10\endlinechar-1\errorcontextlines0\relax @@ -276,16 +385,15 @@ _ / _ / / / /_ / __/ / / /_/ // /__ / /_ _ / __ |/ // __/__ \xs_logo - input is `;'-terminated and can extend over multiple lines - ("\xs_prime_invite" is main input invite, "\xs_second_invite" is continuation prompt) - - definitions are done with `:=' not with `='. -% - any line starting with a control sequence is executed in the -% background, the interrupted numerical input resumes at prompt. - - Magic words: `&pause' (or `;'), `&help', `&bye', - `&exact', `&fp', `&int', `&pol'. + - definitions of variables and functions are done with `:='. \string\jobname is \jobname Transcript will go to log and to \xs_name + Typing at the prompt + - `&pause' or `;' exits to normal TeX (typesetting) interaction, + - `&bye' terminates the session, + - `&help' triggers help panels, + - `&exact', `&fp', `&int', or `&pol' switches among modes. }}% \xdef\xs_welcome_back{\noexpand\message{% You are back to the xintexpr interactive session! @@ -353,7 +461,7 @@ _ / _ / / / /_ / __/ / / /_/ // /__ / /_ _ / __ |/ // __/__ - Polynomials in pol mode are defined using polname(x):=expression; (or with another letter). They can serve as functions in the exact mode. To use a polynomial also as an fp mode function, issue - \PolGenFloatVariant{} at the prompt. + &GenFloat() at the prompt. - Whenever a variable is defined, or a computation is performed, the result is assigned a label @_. These labels are -- cgit v1.2.3