%% This document created by Scientific Notebook (R) Version 3.0


\documentclass[12pt,thmsa]{article}
\usepackage{amssymb}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{sw20jart}

%TCIDATA{TCIstyle=article/art4.lat,jart,sw20jart}

%TCIDATA{<META NAME="ViewSettings" CONTENT="29">}
%TCIDATA{<META NAME="GraphicsSave" CONTENT="32">}
%TCIDATA{<META NAME="Title" CONTENT="Ch. 2: Generating Algorithmic Variations">}
%TCIDATA{Created=Mon Aug 19 14:52:24 1996}
%TCIDATA{LastRevised=Fri Mar 28 19:24:24 1997}
%TCIDATA{Language=American English}
%TCIDATA{CSTFile=Booklet.cst}
%TCIDATA{PageSetup=61,61,114,114,1}
%TCIDATA{<LINK REL="author" HREF="EBfront.tex">}
%TCIDATA{<LINK REL="contents" HREF="EBcontents.tex">}
%TCIDATA{<LINK REL="copyright" HREF="EBfront.tex">}
%TCIDATA{<LINK REL="end" HREF="EBIndex.tex">}
%TCIDATA{<LINK REL="index" HREF="EBIndex.tex">}
%TCIDATA{<LINK REL="next" HREF="EBsource.tex">}
%TCIDATA{<LINK REL="parent" HREF="EBcontents.tex">}
%TCIDATA{<LINK REL="previous" HREF="EBwelcome.tex">}
%TCIDATA{<LINK REL="publisher" HREF="EBfront.tex">}
%TCIDATA{<LINK REL="top" HREF="EBcontents.tex">}
%TCIDATA{<LINK REL="trademark" HREF="EBfront.tex">}
%TCIDATA{AllPages=
%H=78
%F=36
%}


\input{tcilatex}
\begin{document}


\subsection{\textit{Chapter 2 \hrulefill }}

\quad

\section{Generating Algorithmic Variations\label%
{Generating Algorithmic Variations}}

The power of the Exam Builder lies in algorithmic variation---the automatic
generation of slightly differing versions of an exam based on a single set
of algorithmic instructions. With the Exam Builder, you can build
algorithmic variations into your file in several ways. You can

\begin{itemize}
\item  Create questions and answers using definitions, random number
functions, conditions, and formulas.

For each instance of the exam, the Exam Builder\ automatically varies the
content of question statements and multiple-choice answers that are stated
with algorithms.

\item  Change the order of the elements on the exam.

For each instance of the exam, the Exam Builder varies the order of the
questions\ and even varies the order of the items in multiple-choice answer
lists when you specify their permutation. \hyperref{Chapter 4}{}{}{%
EBfrontsection.tex} explains more about permuting exam elements.

\item  Provide several variants for each question.

For each instance of the exam, the Exam Builder randomly selects a different
variant or set of variants. \hyperref{Chapter 5}{}{}{EBquestion.tex}
explains how to use question variants.
\end{itemize}

\subsection{Using definitions\label{Using definitions}}

Instead of writing out each variation of a question and its multiple-choice
answer list, you can vary the questions and answers by stating them with
variables whose values are assigned algorithmically. You can define
variables globally for an entire exam, or locally for a single question or
question variant. If you define variables locally, you can use the same
letters to mean different things in different questions.

With the Exam Builder, you can assign values to variables with two types of
definitions. \emph{Delayed }definitions, which are defined using the symbol $%
=$, are re-evaluated every time the variable is used in the generated exam. 
\emph{Immediate }definitions, which are defined using the symbol $:=$, are
evaluated only once, when the exam file is generated. We recommend that in
most cases you use immediate definitions.

Understanding the difference between the two types of definitions is
important. For example, if you set up a question using the immediate
definition $a:=[$some random number expression$]$, the Exam Builder will use
the expression to define $a$ as a random number. The definition occurs once,
when an exam file is generated. Every time the variable $a$ is evaluated by
the Exam Builder, its value is the same. The value of the variable will
change only if you generate a new exam, at which time the Exam Builder will
generate a new random value for $a$.

On the other hand, if you set up a question using the delayed definition $%
a=[ $some random number expression$]$,\vspace{1pt}the Exam Builder will
define $a $ as the random number expression itself. The Exam Builder will
re-evaluate the expression and generate a new value every time it encounters
the variable $a$ in the question. Therefore, it's possible for the variable
to have different values at different points in the same question.

Because the Exam Builder creates definitions automatically, you must not
provide explicit Maple definitions for variables, as you ordinarily do when
you create mathematics in \textit{Scientific Notebook. }You must not use
the\ Maple New Definition command to create questions in Exam Builder source
files.

\subparagraph{\noindent $\blacktriangleright $\quad \textbf{To enter a
definition\label{Entering a definition}}}

Each definition must be included on its own line in the Setup section for
the exam or for an individual question. \hyperref{Chapter 4}{}{}{%
EBfrontsection.tex} and \hyperref{Chapter 5}{}{}{EBquestion.tex} contain
more information about creating Setup sections.

\begin{enumerate}
\item  Start a new paragraph inside a Setup section.

\item  With the insertion point in mathematics, enter the definition for the
variable.\medskip
\end{enumerate}

\noindent \FRAME{itbpF}{43.125pt}{18.5pt}{4pt}{}{}{ex3.wmf}{\special%
{language "Scientific Word";type "GRAPHIC";maintain-aspect-ratio
TRUE;display "PICT";valid_file "F";width 43.125pt;height 18.5pt;depth
4pt;original-width 48.875pt;original-height 19.5625pt;cropleft "0";croptop
"1";cropright "1";cropbottom "0";filename 'Ex3.wmf';file-properties "NPEU";}}

$m:=15$

$n:=32$

The Exam Builder will use these two immediate definitions to evaluate the
variables $m$ and $n$ when an instance of the exam in which they appear is
generated. If the definitions appear in the Setup section for the exam, the
values will apply to the variables $m$ and $n$ throughout the exam. If the
definitions appear in the Setup section for a question, they will apply to
the variables $m$ and $n$ where they occur in the question.

\subsection{Using random number functions\label%
{Using random number functions}}

Defining variables using random numbers is the basis of creating algorithmic
variations. The basic \textit{Scientific Notebook }random number function is
called \textbf{rand. }When the insertion point is in mathematics and you
type the function name, \textit{Scientific Notebook }automatically
recognizes the function and displays it on your screen in gray letters.
(More information about using mathematical functions in \textit{Scientific
Notebook }is available online via the \hyperref{Help Contents}{}{}{%
Contents.tex}.) You can combine random number functions with definitions to
gain a powerful algorithmic tool.

The $\func{rand}$ function has four forms:\medskip

\begin{itemize}
\item  The form $\func{rand}()$---with no argument---produces a random
integer from a large range.\medskip

\FRAME{itbpF}{43.125pt}{18.5pt}{4pt}{}{}{ex3.wmf}{\special{language
"Scientific Word";type "GRAPHIC";maintain-aspect-ratio TRUE;display
"PICT";valid_file "F";width 43.125pt;height 18.5pt;depth 4pt;original-width
48.875pt;original-height 19.5625pt;cropleft "0";croptop "1";cropright
"1";cropbottom "0";filename 'Ex3.wmf';file-properties "NPEU";}}$\func{rand}%
() $ might yield a number such as $427419669081$, $321110693270$, or $%
343633073697$.\bigskip

\item  The form $\limfunc{rand}(n)$, where $n$ as a single positive integer,
produces a random integer between $0$ and $n-1.\medskip $

\FRAME{itbpF}{43.125pt}{18.5pt}{4pt}{}{}{ex3.wmf}{\special{language
"Scientific Word";type "GRAPHIC";maintain-aspect-ratio TRUE;display
"PICT";valid_file "F";width 43.125pt;height 18.5pt;depth 4pt;original-width
48.875pt;original-height 19.5625pt;cropleft "0";croptop "1";cropright
"1";cropbottom "0";filename 'Ex3.wmf';file-properties "NPEU";}}$\func{rand}%
(10)$ produces one of these numbers: $1,$ $2,$ $3,$ $4,$ $5,$ $6,$ $7,$ $8,$
or $9$.\bigskip

\item  The form $\limfunc{rand}(n,m)$, where $n<m$, produces a random
integer between $n$ and $m$, inclusive.\medskip

\FRAME{itbpF}{43.125pt}{18.5pt}{4pt}{}{}{ex3.wmf}{\special{language
"Scientific Word";type "GRAPHIC";maintain-aspect-ratio TRUE;display
"PICT";valid_file "F";width 43.125pt;height 18.5pt;depth 4pt;original-width
48.875pt;original-height 19.5625pt;cropleft "0";croptop "1";cropright
"1";cropbottom "0";filename 'Ex3.wmf';file-properties "NPEU";}}$\func{rand}%
(2,7)$ produces one of these numbers: $2,$ $3,$ $4,$ $5,$ $6,$ or $7$%
.\bigskip

\item  The form $\limfunc{rand}(\{$some set$\})$ produces an element
selected at random from the specified set.\medskip

\FRAME{itbpF}{43.125pt}{18.5pt}{4pt}{}{}{ex3.wmf}{\special{language
"Scientific Word";type "GRAPHIC";maintain-aspect-ratio TRUE;display
"PICT";valid_file "F";width 43.125pt;height 18.5pt;depth 4pt;original-width
48.875pt;original-height 19.5625pt;cropleft "0";croptop "1";cropright
"1";cropbottom "0";filename 'Ex3.wmf';file-properties "NPEU";}}$\limfunc{rand%
}(\{2,4,6,8\})$ produces one of these numbers: $2,$ $4,$ $6,$ or $8$.\medskip

This form of the function can also be used with expressions. The function $%
\limfunc{rand}(\{\sin x,\cos x\})$ randomly selects either $\sin x$ or $\cos
x$.\bigskip
\end{itemize}

An additional random number function, called \textbf{randmat}, produces
random matrices of various types. The function has this form:\medskip \label%
{Random matrix function}

\begin{center}
$\func{randmat}\left( a,b,c,\left( d\right) \right) $
\end{center}

where

$a$ is the number of matrix rows,

$b$ is the number of matrix columns,

$c$ is the matrix type, with

\qquad 1 = arbitrary

\qquad 2 = symmetric (must be square)

\qquad 3 = antisymmetric (must be square)

\qquad 4 = unimodular and

$\left( d\right) $ is the selection range for the values in the matrix:

\qquad The range $(n),$ with $n$ as a single positive integer, produces
matrix values between $0$ and $n-1.$

\qquad The range $(n,m),$ where $n<m$, produces matrix values between $n$
and $m$, inclusive.

\qquad The range $(\{$some set$\})$ produces matrix values selected at
random from the specified set.\medskip

\noindent \FRAME{itbpF}{43.125pt}{18.5pt}{4pt}{}{}{ex3.wmf}{\special%
{language "Scientific Word";type "GRAPHIC";maintain-aspect-ratio
TRUE;display "PICT";valid_file "F";width 43.125pt;height 18.5pt;depth
4pt;original-width 48.875pt;original-height 19.5625pt;cropleft "0";croptop
"1";cropright "1";cropbottom "0";filename 'Ex3.wmf';file-properties "NPEU";}}%
The function $\func{randmat}\left( 4,4,1,\left( 1,9\right) \right) $
produces a 4$\times $4 arbitrary matrix whose values are between 1 and 9,
inclusive. Here's an example:

\begin{center}
$\func{randmat}\left( 4,4,1,\left( 1,9\right) \right) =\allowbreak 
\begin{array}{cccc}
7 & 8 & 8 & 4 \\ 
1 & 3 & 4 & 3 \\ 
4 & 4 & 8 & 9 \\ 
4 & 6 & 1 & 6
\end{array}
\medskip $
\end{center}

\subparagraph{\noindent $\blacktriangleright $\quad \textbf{To enter a
random number function}\protect\vspace{1pt}\label%
{Entering a random number function}}

\begin{enumerate}
\item  With the insertion point in mathematics, type \textbf{rand }\ to
enter a random number function or \textbf{randmat }to enter a random matrix.

On your screen you see $\func{rand}$ or $\func{randmat}$.

\item  Click \FRAME{itbpF}{16.6875pt}{16pt}{2pt}{}{}{parens.wmf}{\special%
{language "Scientific Word";type "GRAPHIC";maintain-aspect-ratio
TRUE;display "PICT";valid_file "F";width 16.6875pt;height 16pt;depth
2pt;original-width 17.8125pt;original-height 16.9375pt;cropleft "0";croptop
"1";cropright "1";cropbottom "0";filename 'Parens.wmf';file-properties
"XNPEU";}}.

\item  Complete the function argument.
\end{enumerate}

You can also enter the functions by choosing them from the popup list in the
Fragments toolbar or using the Import Fragment command on the File menu.

\noindent \FRAME{itbpF}{43.125pt}{18.5pt}{4pt}{}{}{ex3.wmf}{\special%
{language "Scientific Word";type "GRAPHIC";maintain-aspect-ratio
TRUE;display "PICT";valid_file "F";width 43.125pt;height 18.5pt;depth
4pt;original-width 48.875pt;original-height 19.5625pt;cropleft "0";croptop
"1";cropright "1";cropbottom "0";filename 'Ex3.wmf';file-properties "NPEU";}}

$a:=\func{rand}(2,7)$

$b:=\func{rand}(10)$

$c:=a+b$

\noindent The Exam Builder will use the random number functions in these
immediate definitions to generate values for $a$ and $b$ and to evaluate $c$
each time an instance of the exam is generated from the source file.

\subsection{Using conditions\label{Using conditions}}

If you simply generate a random number for use in a definition, the results
can at times be unpredictable, but you can prevent such results if you
specify conditions that randomly defined variables must meet. For example,
you might set a condition that prevents a variable from being defined as $0$
or a condition that prevents one variable from being greater than another.

When you use algorithms to state not only a question but also its
multiple-choice answers, you can use conditions to prevent the random
generation of duplicate or undefined answers. For example, a question that
involves two randomly generated variables $a$ and $b$ might have as possible
multiple-choice answers both $\frac{a}{b}$ and $\frac{b}{a}.$ If the
randomly generated values for the variables are the same, these answers will
be identical and will present a confusing choice to the student. You can
avoid the confusion by setting the condition that $(a\neq b).$ You also want
to avoid the illegal situations of $(a=0)$ and $(b=0)$.

Like the definitions to which they refer, conditions can affect an entire
exam or just a single question or question variant. Also like definitions,
each condition must be stated on its own line in a Setup section. (Refer to 
\hyperref{Chapter 4}{}{}{EBfrontsection.tex} and \hyperref{Chapter 5}{}{}{%
EBquestion.tex} for more information about creating Setup sections.)
Further, each condition must follow the definition to which it refers. You
can use logical and ($\wedge $)\ and logical or ($\vee $) to combine several
conditions in a single statement.

Note that the conditions must be relatively easy to satisfy. If after
several hundred attempts the Exam Builder can't find a random assignment to
the variables that satisfies the conditions, it returns undefined results.

\subparagraph{\noindent $\blacktriangleright $\quad \textbf{To enter a
condition\label{Entering a condition}}}

\begin{enumerate}
\item  Start a new paragraph after the definition for which you want to
state conditions.

\item  Type \textsf{Condition: }and then, with the insertion point in
mathematics, type the condition the variable must meet.

The word Condition is a \emph{keyword,} which triggers certain effects when
the Exam Builder generates the exam. \hyperref{Chapter 3}{}{}{EBsource.tex}
explains more about keywords.
\end{enumerate}

\noindent \FRAME{itbpF}{42.875pt}{18.125pt}{4pt}{}{}{ex3.wmf}{\special%
{language "Scientific Word";type "GRAPHIC";maintain-aspect-ratio
TRUE;display "PICT";valid_file "F";width 42.875pt;height 18.125pt;depth
4pt;original-width 48.875pt;original-height 19.5625pt;cropleft "0";croptop
"1";cropright "1";cropbottom "0";filename 'Ex3.wmf';file-properties "NPEU";}}%
Condition: $(ab\neq 0)$

\noindent This condition specifies that neither $a$ nor $b$ can equal $0$.
The Exam Builder will reject a randomly generated value of $0$ for either
variable.

\noindent \FRAME{itbpF}{42.875pt}{18.125pt}{4pt}{}{}{ex3.wmf}{\special%
{language "Scientific Word";type "GRAPHIC";maintain-aspect-ratio
TRUE;display "PICT";valid_file "F";width 42.875pt;height 18.125pt;depth
4pt;original-width 48.875pt;original-height 19.5625pt;cropleft "0";croptop
"1";cropright "1";cropbottom "0";filename 'Ex3.wmf';file-properties "NPEU";}}

\noindent This simple example shows how you can combine definitions, random
number functions, and conditions to generate suitable variable values for
your questions and answers.

$a:=\func{rand}(10)$

$b:=\func{rand}(10)$

$c:=a+b$

Condition: $(a\neq b)$

\noindent This condition specifies that $a$ and $b$ cannot be equal. The
Exam Builder will reject a randomly generated value for $b$ if it is the
same as the value already generated for $a$.

\noindent \FRAME{itbpF}{43.125pt}{18.5pt}{4pt}{}{}{ex3.wmf}{\special%
{language "Scientific Word";type "GRAPHIC";display "PICT";valid_file
"F";width 43.125pt;height 18.5pt;depth 4pt;original-width
48.875pt;original-height 19.5625pt;cropleft "0";croptop "1";cropright
"1";cropbottom "0";filename 'Ex3.wmf';file-properties "NPEU";}}Here is a
condition that is very hard to satisfy:

$a:=\func{rand}(1000000)$

$b:=\func{rand}(1000000)$

Condition: $(a=b)$

This condition will not be satisfied very often because what are the chances
that two numbers selected at random from the specified range will be equal?

\subsection{Using formulas\label{Using formulas}}

Once you have defined the variables for a particular question, you can use
formulas to state the question and the corresponding multiple-choice
answers. A formula is a special type of mathematical expression that is
evaluated before it is displayed in your file. For example, if you enter a
formula consisting of the simple expression $3+5$, \textit{Scientific
Notebook }displays $%
%TCIMACRO{\FORMULA{3+5}{8}{evaluate}}
%BeginExpansion
8%
%EndExpansion
$ in your file. Similarly, if you enter $(a+b)(a+b)$ as a formula, \textit{%
Scientific Notebook }displays\ $%
%TCIMACRO{\FORMULA{(a+b)(a+b)}{\left( a+b\right) ^{2}}{evaluate}}
%BeginExpansion
\left( a+b\right) ^{2}%
%EndExpansion
$\textit{\ }in your file.\ If you have Helper Lines turned on in the View
menu, formulas appear against a colored background, as shown here. If you
have Helper Lines turned off, formulas are visually indistinguishable from
ordinary mathematical expressions.

Note that if the expression in a formula includes variables determined by
random number functions or by certain mathematical operations, \textit{%
Scientific Notebook }may not have all the information it needs to display
the fully evaluated formula until it generates an exam file. For example, if
as noted above you enter $(a+b)(a+b)$ as a formula and then use random
number functions to define $a$ and $b$, \textit{Scientific Notebook }%
displays\ $%
%TCIMACRO{\FORMULA{(a+b)(a+b)}{\left( a+b\right) ^{2}}{evaluate}}
%BeginExpansion
\left( a+b\right) ^{2}%
%EndExpansion
$\textit{\ }in your source file. It can't evaluate the expression further
until the random values are assigned to the variables, which doesn't occur
until the exam file is generated. At that time, if $a=2$ and $b=3$ , the
formula appears as $%
%TCIMACRO{\FORMULA{\left( 2+3\right) ^{2}}{25}{evaluate}}
%BeginExpansion
25%
%EndExpansion
\ $in the generated exam.\ You should ignore the formula that appears in the
Exam Builder source file, which may differ significantly from both the
statement of the formula and the fully evaluated form of the formula. You
can see the formula in its unevaluated form if you double-click it.

\subparagraph{\noindent $\blacktriangleright $\quad To create a formula\label%
{Creating a formula}}

\begin{enumerate}
\item  If the Field toolbar is displayed, click\FRAME{itbpF}{21.75pt}{%
21.0625pt}{2pt}{}{}{formula.wmf}{\special{language "Scientific Word";type
"GRAPHIC";display "PICT";valid_file "F";width 21.75pt;height 21.0625pt;depth
2pt;original-width 19.5625pt;original-height 18.8125pt;cropleft "0";croptop
"1";cropright "1";cropbottom "0";filename 'formula.wmf';file-properties
"XNPEU";}},. Otherwise,from the Insert menu, choose Field and then choose
Formula.

\item  In the Formula area of the dialog box, enter a mathematical
expression.

\item  In the Operation area, enter the computational operation you want to
perform on the expression.

Click the arrow at the right of the box for a list of available operations.

\item  Choose OK.

If Helper Lines are turned on in the View menu, the formula appears against
a colored background.
\end{enumerate}

\subsection{Building questions with algorithms\label%
{Building questions with algorithms}}

Definitions, conditions, random number functions, and formulas all work
together in Exam Builder questions and answers, as shown in the examples
that follow. \hyperref{Chapter 5}{}{}{EBquestion.tex} explains how to
structure questions and answers for the Exam Builder.

\noindent \FRAME{itbpF}{42.875pt}{18.125pt}{4pt}{}{}{ex3.wmf}{\special%
{language "Scientific Word";type "GRAPHIC";maintain-aspect-ratio
TRUE;display "PICT";valid_file "F";width 42.875pt;height 18.125pt;depth
4pt;original-width 48.875pt;original-height 19.5625pt;cropleft "0";croptop
"1";cropright "1";cropbottom "0";filename 'Ex3.wmf';file-properties "NPEU";}}

\noindent Define the variable $n$ as a randomly selected prime number:

$n:=\limfunc{rand}(\{5,7,11,13\})$

\noindent Ask the student to identify the prime number in a list of answers,
each of which has been defined using formulas:

\begin{itemize}
\item  $%
%TCIMACRO{\FORMULA{n}{n}{evaluate}}
%BeginExpansion
n%
%EndExpansion
$

\item  $%
%TCIMACRO{\FORMULA{2n}{2n}{evaluate}}
%BeginExpansion
2n%
%EndExpansion
$

\item  $%
%TCIMACRO{\FORMULA{3n}{3n}{evaluate}}
%BeginExpansion
3n%
%EndExpansion
$

\item  $%
%TCIMACRO{\FORMULA{n-1}{n-1}{evaluate}}
%BeginExpansion
n-1%
%EndExpansion
\bigskip $
\end{itemize}

\noindent \FRAME{itbpF}{42.875pt}{18.125pt}{4pt}{}{}{ex3.wmf}{\special%
{language "Scientific Word";type "GRAPHIC";maintain-aspect-ratio
TRUE;display "PICT";valid_file "F";width 42.875pt;height 18.125pt;depth
4pt;original-width 48.875pt;original-height 19.5625pt;cropleft "0";croptop
"1";cropright "1";cropbottom "0";filename 'Ex3.wmf';file-properties "NPEU";}}

\noindent Define several variables with random functions and restrict the
definitions with conditions:

$a:=\{2,3,5,7,11,23\}$

$b:=\func{rand}(a)$

$c:=\func{rand}(a)$

Conditions:$(b\neq c)\wedge (b<c)$\vspace{1pt}

\noindent State the question using several simple formulas:

If $x+%
%TCIMACRO{\FORMULA{b}{b}{evaluate}}
%BeginExpansion
b%
%EndExpansion
=%
%TCIMACRO{\FORMULA{c}{c}{evaluate}}
%BeginExpansion
c%
%EndExpansion
$, then $x$ is:

\noindent Use additional formulas to determine several possible answers:

\begin{itemize}
\item  $%
%TCIMACRO{\FORMULA{c-b}{c-b}{evaluate}}
%BeginExpansion
c-b%
%EndExpansion
$

\item  $%
%TCIMACRO{\FORMULA{b-c}{b-c}{evaluate}}
%BeginExpansion
b-c%
%EndExpansion
$

\item  $%
%TCIMACRO{\FORMULA{c-b+1}{c-b+1}{evaluate}}
%BeginExpansion
c-b+1%
%EndExpansion
$\bigskip
\end{itemize}

\noindent \FRAME{itbpF}{42.875pt}{18.125pt}{4pt}{}{}{ex3.wmf}{\special%
{language "Scientific Word";type "GRAPHIC";maintain-aspect-ratio
TRUE;display "PICT";valid_file "F";width 42.875pt;height 18.125pt;depth
4pt;original-width 48.875pt;original-height 19.5625pt;cropleft "0";croptop
"1";cropright "1";cropbottom "0";filename 'Ex3.wmf';file-properties "NPEU";}}

\noindent This example is somewhat more complicated. Define several sets of
variables with random number functions, then define additional variables
using the first set of definitions:

$a:=\limfunc{rand}(1,100)$

$b:=\limfunc{rand}(1,100)$

$p:=\limfunc{rand}(\{3,5,7,11,13,17,19\})$ [some primes]

Condition: $\gcd (a,p)=1$

Condition:\ $\gcd (b,p)=1$

$A:=\left( -(b/a)\func{mod}p\right) $

$B:=\left( -(b/a+1)\func{mod}p\right) $

$C:=\left( -(b/a-1)\func{mod}p\right) $

\noindent Use formulas to state the question for the student:

Solve the congruence $%
%TCIMACRO{\FORMULA{aX+b}{aX+b}{evaluate}}
%BeginExpansion
aX+b%
%EndExpansion
=0\func{mod}%
%TCIMACRO{\FORMULA{p}{p}{evaluate}}
%BeginExpansion
p%
%EndExpansion
$.

\noindent Use additional formulas to present the possible answers:

\begin{itemize}
\item  $%
%TCIMACRO{\FORMULA{A}{A}{evaluate}}
%BeginExpansion
A%
%EndExpansion
$

\item  $%
%TCIMACRO{\FORMULA{B}{B}{evaluate}}
%BeginExpansion
B%
%EndExpansion
$

\item  $%
%TCIMACRO{\FORMULA{C}{C}{evaluate}}
%BeginExpansion
C%
%EndExpansion
$
\end{itemize}

\end{document}
