% Torture test for math fonts.
\ifx\undefined\eplain \input eplain \fi

%\tracingoutput = 1
%\tracingboxes

%\input lucidamath


% Change general typesetting parameters.
% 
\rm
\headline = {{\tenrm\folio} \hfil \timestamp}
\footline = {}
\advance\vsize by .1in
\raggedbottom
\raggedright
\rightskip = 2em plus 5em minus 2em
\parindent = 0pt
\parskip = .5\baselineskip



% Test the basic character repertoire: we go through the math symbols
% listed in Appendix F of the TeXbook.  This code is based on the \math
% test in testfont.tex.  

% Apply \\ to roman and Greek upper- and lowercase, and script
% uppercase.  Use \ii and \jj for `i' and `j', since sometimes we want
% the dotless versions.
\def\lettertrial{Letters: $
  \\A \\B \\C \\D \\E \\F \\G \\H \\I \\J \\K \\L \\M \\N \\O \\P \\Q
  \\R \\S \\T \\U \\V \\W \\X \\Y \\Z
  $\par$
  \\a \\b \\c \\d \\e \\f \\g \\h \\\ii \\\jj \\k \\l \\m \\n \\o \\p
  \\q \\r \\s \\t \\u \\v \\w \\x \\y \\z
  $\par$
  \\\alpha \\\beta \\\gamma \\\delta \\\epsilon \\\zeta \\\eta \\\theta
  \\\vartheta \\\iota \\\kappa \\\lambda \\\mu \\\nu \\\xi \\\pi
  \\\varpi \\\rho \\\sigma \\\tau \\\upsilon \\\phi \\\varphi \\\chi
  \\\psi \\\omega
  $\par$
  \\\Gamma \\\Delta \\\Theta \\\Lambda \\\Xi \\\Pi \\\Sigma \\\Upsilon
  \\\Phi \\\Psi \\\Omega
  $\par$
  \\\scriptA \\\scriptB \\\scriptC \\\scriptD \\\scriptE \\\scriptF
  \\\scriptG \\\scriptH \\\scriptI \\\scriptJ \\\scriptK \\\scriptL
  \\\scriptM \\\scriptN \\\scriptO \\\scriptP \\\scriptQ \\\scriptR
  \\\scriptS \\\scriptT \\\scriptU \\\scriptV \\\scriptW \\\scriptX
  \\\scriptY \\\scriptZ
  $\par
}

% Test miscellanous Ord symbols, except for \imath and \jmath.
\def\miscordtrial{Miscellanous ordinary symbols: $
  \\\aleph \\\hbar \\\ell \\\wp \\\Re \\\Im \\\partial \\\infty
  \\\emptyset \\\nabla \\\surd \\\top \\\bot \\\| \\\angle \\\triangle
  \\\backslash \\\forall \\\exists \\\neg \\\flat \\\natural \\\sharp
  \\\clubsuit \\\diamondsuit \\\heartsuit \\\spadesuit \\! \\? \\. \\|
  \\/ \\` \\@ \\"
  $\par
}

% Test the various styles of digits.
\def\digittest{Digits: $0123456789$, $\oldstyle 0123456789$\par}

% Test large operators.
\def\largeoptrial{Large operators: $
  \\\sum \\\prod \\\coprod \\\int \\\oint \\\bigcap \\\bigcup
  \\\bigsqcup \\\bigvee \\\bigwedge \\\bigodot \\\bigotimes \\\bigoplus
  \\\biguplus
  $\par
}

% Binary operators.
\def\binoptrial{Binary operators: $
  \\\pm \\\cap \\\vee \\\mp \\\cup \\\wedge \\\setminus \\\uplus
  \\\oplus \\\cdot \\\sqcap \\\ominus \\\times \\\sqcup \\\otimes \\\ast
  \\\triangleleft \\\oslash \\\star \\\triangleright \\\odot \\\diamond
  \\\wr \\\dagger \\\circ \\\bigcirc \\\ddagger \\\bullet
  \\\bigtriangleup \\\amalg \\\div \\\bigtriangledown \\* \\+ \\-
  $\par
}

% \bmod and \pmod, from p.164 of the TeXbook.
\def\modtest{Mod: 
  $\gcd(m,n) = \gcd(n,m \bmod n)$, and
  $x\equiv y+1 \pmod{m^2}$.
  \par
}


% Relations.
\def\relationtrial{Relations: $
  \\\leq \\\geq \\\equiv \\\prec \\\succ \\\approx \\\preceq \\\succeq
  \\\propto \\\ll \\\gg \\\asymp \\\subset \\\supset \\\sim \\\subseteq
  \\\supseteq \\\simeq \\\sqsubseteq \\\sqsupseteq \\\cong \\\in \\\ni
  \\\bowtie \\\vdash \\\dashv \\\models \\\smile \\\mid \\\doteq
  \\\frown \\\parallel \\\perp \\= \\< \\> \\\ne \\:
  $\par
}

% Negated relations.
\def\negrelationtrial{Negated \begingroup
  \let\temp = \\%
  \def\\##1{\temp{\not##1}}%
  \let\par = \relax
  \relationtrial
  $\temp\notin$
  \endgraf
\endgroup}

% Arrows.
\def\arrowtrial{Arrows: $
 \\\leftarrow \\\longleftarrow \\\uparrow \\\Leftarrow \\\Longleftarrow
 \\\Uparrow \\\rightarrow \\\longrightarrow \\\downarrow \\\Rightarrow
 \\\Longrightarrow \\\Downarrow \\\leftrightarrow \\\longleftrightarrow
 \\\updownarrow \\\Leftrightarrow \\\Longleftrightarrow \\\Updownarrow
 \\\mapsto \\\longmapsto \\\nearrow \\\hookleftarrow \\\hookrightarrow
 \\\searrow \\\leftharpoonup \\\rightharpoonup \\\swarrow
 \\\leftharpoondown \\\rightharpoondown \\\nwarrow \\\rightleftharpoons
 $\par
}

% \buildrel.
\def\buildreltest{Buildrel:
  $\buildrel \alpha\beta \over \longrightarrow$, and
  $\buildrel \rm def \over =$.
  \par
}

% Delimiters are more complicated, since we want to see them grow.  This
% code is from the Metafontbook, the end of Appendix H.
\let\interitem = .
\newcount\delimpaircount

\def\testdelimpair#1#2{%
  \Bigggl{#1}\interitem
  \bigggl{#1}\interitem
  \Biggl{#1}\interitem
  \biggl{#1}\interitem
  \Bigl{#1}\interitem
  \bigl{#1}\interitem
  \left#1 \bullet
  \right#2\interitem
  \bigr{#2}\interitem
  \Bigr{#2}\interitem
  \biggr{#2}\interitem
  \Biggr{#2}\interitem
  \bigggr{#2}\interitem
  \Bigggr{#2}%
  \advance\delimpaircount by 1
  \ifodd\delimpaircount \hfil \else \expandafter \foo \fi
}

\def\foo{\cr}

\def\delimtest{Delimiters: $$\displaylines{\delimpaircount = 0
  \testdelimpair ()
  \testdelimpair \lbrack\rbrack
  \testdelimpair \lgroup\rgroup
  \testdelimpair \lmoustache\rmoustache
  \testdelimpair \vert\Vert
  \testdelimpair \arrowvert\Arrowvert
  \testdelimpair \uparrow\downarrow
  \testdelimpair \updownarrow\Updownarrow
  \testdelimpair \Uparrow\Downarrow
  \testdelimpair \bracevert{\delimiter"342}
  \testdelimpair \backslash/
  \testdelimpair \langle\rangle
  \testdelimpair \lbrace\rbrace
  \testdelimpair \lceil\rceil
  \testdelimpair \lfloor\rfloor
  \crcr
  }$$
  %
  % Throw in square roots, too, as long as we're here.
  $$\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{-1}}}}}}}}}$$
}

% Punctuation.
\def\puncttest{Punctuation: 
  $f\colon A\rightarrow B$,
  $L(a, b; c\colon x, y;z)$,
  $a.b : c, d$,
  \dots, and $x_1 + \cdots + x_n$,
  don't forget $f(x_1, \ldots, x_n)$.
  \par
}



% Test fractions.
\def\fractiontrial{Fractions: $
  \\\over
  \\\atop
  \\\choose
  \\{\above.5pt}
  \\{\overwithdelims<>}
  \\{\atopwithdelims[]}
  \\{\abovewithdelims\lbrace\rbrace1pt}
  $\par
}

% Test roots.
\def\roottest{Roots:
  $\sqrt{2i}$,
  $\root 3 \of 2$,
  $\root n \of {x^n + y^n}$,
  $\sqrt{\mathstrut a} + \sqrt{\mathstrut d} + \sqrt{\mathstrut y}$,
  and $\root n+1 \of Q$.
  \par
}

% Test various fills.
\def\filltrial{Filling: $
  \\\overline \\\underline \\\widehat
  \\\widetilde \\\overbrace \\\underbrace
  $\par
}

% Test accents.
\def\accenttrial{Accents: $
  \let\ii = \imath
  \let\jj = \jmath
  \\\hat \\\check \\\tilde \\\acute \\\grave \\\dot \\\ddot \\\breve
  \\\bar \\\vec
  $\par
}



% Challenges, from pp.180-182 of the TeXbook.
\def\challenge{
$n^{\rm th}$ root

% \bf omitted here, since we're not trying to test bold.
${S^{\rm-1}TS=dg}(\omega_1,\ldots,\omega_n) =\Lambda$

$\Pr(\,m=n\mid m+n=3\,)$

$\sin18^\circ={1\over4}(\sqrt5-1)$

$k=1.38\times10^{-16}\rm\,erg/^\circ K$

$\bar\Phi\subset NL_1^*/N=\bar L_1^*
          \subseteq\cdots\subseteq NL_n^*/N=\bar L_n^*$

$I(\lambda)=\int\!\!\int_Dg(x,y)e^{i\lambda h(x,y)}\,dx\,dy$

$\int_0^1\!\cdots\int_0^1f(x_1,\ldots,x_n)\,dx_1\ldots\,dx_n$

$$x_{2m}\equiv\cases{Q(X_m^2-P_2W_m^2)-2S^2&($m$ odd)\cr
               \noalign{\vskip2pt} % spread the lines apart a little
               P_2^2(X_m^2-P_2W_m^2)-2S^2&($m$ even)\cr}\pmod N.$$

$$(1+x_1z+x_1^2z^2+\cdots\,)\ldots(1+x_nz+x_n^2z^2+\cdots\,)
          ={1\over(1-x_1z)\ldots(1-x_nz)}.$$
        
$$\prod_{j\ge0}\biggl(\sum_{k\ge0}a_{jk}z^k\biggr)
    =\sum_{n\ge0}z^n\,\Biggl(\sum_
       {\scriptstyle k_0,k_1,\ldots\ge0\atop
        \scriptstyle k_0+k_1+\cdots=n}
     a_{0k_0}a_{1k_1}\ldots\,\Biggr).$$

$${(n_1+n_2+\cdots+n_m)!\over n_1!\,n_2!\ldots n_m!}
    ={n_1+n_2\choose n_2}{n_1+n_2+n_3\choose n_3}
      \ldots{n_1+n_2+\cdots+n_m\choose n_m}.$$

$$\def\\##1##2{(1-q^{##1_##2+n})} % to save typing
  \Pi_R{a_1,a_2,\ldots,a_M\atopwithdelims[]b_1,b_2,\ldots,b_N}
    =\prod_{n=0}^R{\\a1\\a2\ldots\\aM\over\\b1\\b2\ldots\\bN}.$$

$$\sum_{p\rm\;prime}f(p)=\int_{t>1}f(t)\,d\pi(t).$$

$$\{\underbrace{\overbrace{\mathstrut a,\ldots,a}
        ^{k\;a\mathchar`'\rm s},
      \overbrace{\mathstrut b,\ldots,b}
        ^{l\;b\mathchar`'\rm s}}_{k+l\rm\;elements}\}.$$
        
$$\pmatrix{\pmatrix{a&b\cr c&d\cr}&
               \pmatrix{e&f\cr g&h\cr}\cr
             \noalign{\smallskip}
             0&\pmatrix{i&j\cr k&l\cr}\cr}.$$

$$\det\left|\,\matrix{
    c_0&c_1\hfill&c_2\hfill&\ldots&c_n\hfill\cr
    c_1&c_2\hfill&c_3\hfill&\ldots&c_{n+1}\hfill\cr
    c_2&c_3\hfill&c_4\hfill&\ldots&c_{n+2}\hfill\cr
    \,\vdots\hfill&\,\vdots\hfill&
         \,\vdots\hfill&&\,\vdots\hfill\cr
    c_n&c_{n+1}\hfill&c_{n+2}\hfill&\ldots&c_{2n}\hfill\cr
    }\right|>0.$$

$$\mathop{{\sum}'}_{x\in A}f(x)\mathrel{\mathop=^{\rm def}}
    \sum_{\scriptstyle x\in A\atop\scriptstyle x\ne0}f(x).$$

$$2\uparrow\uparrow k\mathrel{\mathop=^{\rm def}}
    2^{2^{2^{\cdot^{\cdot^{\cdot^2}}}}}
      \vbox{\hbox{$\Big\}\scriptstyle k$}\kern0pt}.$$

$$\def\normalbaselines{\baselineskip20pt
    \lineskip3pt \lineskiplimit3pt }
  \def\mapright##1{\smash{
      \mathop{\longrightarrow}\limits^{##1}}}
  \def\mapdown##1{\Big\downarrow
    \rlap{$\vcenter{\hbox{$\scriptstyle##1$}}$}}
  \matrix{&&&&&&0\cr
    &&&&&&\mapdown{}\cr
    0&\mapright{}&{\cal O}_C&\mapright\iota&
      \cal E&\mapright\rho&\cal L&\mapright{}&0\cr
    &&\Big\Vert&&\mapdown\phi&&\mapdown\psi\cr
    0&\mapright{}&{\cal O}_C&\mapright{}&
      \pi_*{\cal O}_D&\mapright\delta&
      R^1f_*{\cal O}_V(-D)&\mapright{}&0\cr
    &&&&&&\mapdown{\theta_i\otimes\gamma^{-1}}\cr
    &&&&&&\hidewidth R^1f_*\bigl({\cal O}
      _V(-iM)\bigr)\otimes\gamma^{-1}\hidewidth\cr
    &&&&&&\mapdown{}\cr
    &&&&&&0\cr}$$
}



% We need the calligraphic capitals available via a control sequence.
\def\scriptA{{\cal A}} \def\scriptN{{\cal N}}
\def\scriptB{{\cal B}} \def\scriptO{{\cal O}}
\def\scriptC{{\cal C}} \def\scriptP{{\cal P}}
\def\scriptD{{\cal D}} \def\scriptQ{{\cal Q}}
\def\scriptE{{\cal E}} \def\scriptR{{\cal R}}
\def\scriptF{{\cal F}} \def\scriptS{{\cal S}}
\def\scriptG{{\cal G}} \def\scriptT{{\cal T}}
\def\scriptH{{\cal H}} \def\scriptU{{\cal U}}
\def\scriptI{{\cal I}} \def\scriptV{{\cal V}}
\def\scriptJ{{\cal J}} \def\scriptW{{\cal W}}
\def\scriptK{{\cal K}} \def\scriptX{{\cal X}}
\def\scriptL{{\cal L}} \def\scriptY{{\cal Y}}
\def\scriptM{{\cal M}} \def\scriptZ{{\cal Z}}


% Even bigger sizes than plain provides.
\def\biggg#1{{\hbox{$\left#1\vbox to20.5pt{}\right.$}}}
\def\bigggl{\mathopen\biggg}
\def\bigggr{\mathclose\biggg}
\def\Biggg#1{{\hbox{$\left#1\vbox to23.5pt{}\right.$}}}
\def\Bigggl{\mathopen\Biggg}
\def\Bigggr{\mathclose\Biggg}


% Ordinarily, use the normal letters.
\let\ii = i
\let\jj = j


% Run #1 in each of the four main styles.
\def\styletest#1{\begingroup
  (Display style) \everymath = {\displaystyle}#1%
  (Text style) \everymath = {\textstyle}#1%
  (Script style) \everymath = {\scriptstyle}#1%
  (Scriptscript style) \everymath = {\scriptscriptstyle}#1%
\endgroup}


\def\printparam#1{%
  $\hbox{\tt #1} = \hbox{\rm \expandafter\the\csname #1\endcsname}$%
}

\def\interspace{\allowbreak\hskip 1em plus.5em minus.5em}



% Run the tests.
Testing with \printparam{thinmuskip}, \printparam{medmuskip},
\printparam{thickmuskip}, \printparam{scriptspace},
\printparam{delimitershortfall}, \printparam{delimiterfactor},
\printparam{mathsurround}, \printparam{nulldelimiterspace}.


\def\\#1{-#1'}\lettertrial
\def\\#1{\allowbreak\quad#1x}\miscordtrial
\styletest\digittest

% Tests the large operators first in text size, then display size.
\def\\#1{#1^a_b B\interspace}\largeoptrial
\def\\#1{\displaystyle #1^b_a B \interspace}\largeoptrial

\def\\#1{A#1x\allowbreak\quad}\binoptrial
\styletest\modtest

\def\\#1{x#1A\allowbreak\quad}\relationtrial
\def\\#1{y#1B\allowbreak\quad}\negrelationtrial
\def\\#1{B#1y\allowbreak\quad}\arrowtrial
\styletest\buildreltest
\delimtest
\styletest\puncttest

\def\\#1{{Z #1 W}\interspace}\fractiontrial
\def\\#1{{g #1 d}\interspace}\fractiontrial
\def\\#1{{b #1 a}\interspace}\fractiontrial

\styletest\roottest

\def\\#1{#1{o}\interspace}\filltrial
\def\\#1{#1{A + \cdots - Q - \cdots + g}\interspace}\filltrial

\def\\#1{- #1A + #1q}\accenttrial

\challenge

\bye
