File:
[LON-CAPA] /
capa /
capa51 /
Manual /
s-functions.tex
Revision
1.1:
download - view:
text,
annotated -
select for diffs
Fri Jul 14 18:30:33 2000 UTC (24 years, 3 months ago) by
albertel
Branches:
MAIN
CVS tags:
version_2_9_X,
version_2_9_99_0,
version_2_9_1,
version_2_9_0,
version_2_8_X,
version_2_8_99_1,
version_2_8_99_0,
version_2_8_2,
version_2_8_1,
version_2_8_0,
version_2_7_X,
version_2_7_99_1,
version_2_7_99_0,
version_2_7_1,
version_2_7_0,
version_2_6_X,
version_2_6_99_1,
version_2_6_99_0,
version_2_6_3,
version_2_6_2,
version_2_6_1,
version_2_6_0,
version_2_5_X,
version_2_5_99_1,
version_2_5_99_0,
version_2_5_2,
version_2_5_1,
version_2_5_0,
version_2_4_X,
version_2_4_99_0,
version_2_4_2,
version_2_4_1,
version_2_4_0,
version_2_3_X,
version_2_3_99_0,
version_2_3_2,
version_2_3_1,
version_2_3_0,
version_2_2_X,
version_2_2_99_1,
version_2_2_99_0,
version_2_2_2,
version_2_2_1,
version_2_2_0,
version_2_1_X,
version_2_1_99_3,
version_2_1_99_2,
version_2_1_99_1,
version_2_1_99_0,
version_2_1_3,
version_2_1_2,
version_2_1_1,
version_2_1_0,
version_2_12_X,
version_2_11_X,
version_2_11_5_msu,
version_2_11_5,
version_2_11_4_uiuc,
version_2_11_4_msu,
version_2_11_4,
version_2_11_3_uiuc,
version_2_11_3_msu,
version_2_11_3,
version_2_11_2_uiuc,
version_2_11_2_msu,
version_2_11_2_educog,
version_2_11_2,
version_2_11_1,
version_2_11_0_RC3,
version_2_11_0_RC2,
version_2_11_0_RC1,
version_2_11_0,
version_2_10_X,
version_2_10_1,
version_2_10_0_RC2,
version_2_10_0_RC1,
version_2_10_0,
version_2_0_X,
version_2_0_99_1,
version_2_0_2,
version_2_0_1,
version_2_0_0,
version_1_99_3,
version_1_99_2,
version_1_99_1_tmcc,
version_1_99_1,
version_1_99_0_tmcc,
version_1_99_0,
version_1_3_X,
version_1_3_3,
version_1_3_2,
version_1_3_1,
version_1_3_0,
version_1_2_X,
version_1_2_99_1,
version_1_2_99_0,
version_1_2_1,
version_1_2_0,
version_1_1_X,
version_1_1_99_5,
version_1_1_99_4,
version_1_1_99_3,
version_1_1_99_2,
version_1_1_99_1,
version_1_1_99_0,
version_1_1_3,
version_1_1_2,
version_1_1_1,
version_1_1_0,
version_1_0_99_3,
version_1_0_99_2,
version_1_0_99_1,
version_1_0_99,
version_1_0_3,
version_1_0_2,
version_1_0_1,
version_1_0_0,
version_0_99_5,
version_0_99_4,
version_0_99_3,
version_0_99_2,
version_0_99_1,
version_0_99_0,
version_0_6_2,
version_0_6,
version_0_5_1,
version_0_5,
version_0_4,
version5-1-2-first_release,
stable_2002_spring,
stable_2002_july,
stable_2002_april,
stable_2001_fall,
loncapaMITrelate_1,
language_hyphenation_merge,
language_hyphenation,
conference_2003,
bz6209-base,
bz6209,
STABLE,
HEAD,
GCI_3,
GCI_2,
GCI_1,
CAPA_5-1-6,
CAPA_5-1-5,
CAPA_5-1-4_RC1,
BZ4492-merge,
BZ4492-feature_horizontal_radioresponse,
BZ4492-feature_Support_horizontal_radioresponse,
BZ4492-Support_horizontal_radioresponse
- added the manual
\hrule
\vskip 0.2in
\section{\capa{} Functions}
\vskip 0.2in
\hrule
\vskip 0.2in
%>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
All of the examples and descriptions used below are for
student submissions of answers through a Web or telnet session.
There are some changes and additions to the {\sl set$x$.qz} code when using
\capa\ for machine scored exams. Please see the next section for those
examples.
\subsection{\bf Question source text}
\capa\ assumes that any characters in the
{\sl set$x$.qz} without a special command at the beginning of a line will be
displayed as text for the student. The following are those special commands: \\
{\tt /LET, \ /BEG, \ /DIS, \ /IMP, \ //, \ /HIN, \ /EXP, \ /MAP, \ /RMAP, \
/IF, \ /ELSE, \ /ENDIF, \ /WHILE, \ /ENDWHILE, \ /ANS, \ /AND, \ /OR, \ /SUBJECTIVE, \ /VERB, \ /ENDVERB, \ /START,} and \ {\tt /END}.\\
Text (excluding white space) preceding the forward slash will disable the all
of the commands except {\tt //} and {\tt /DIS}. Variables must be defined
before use.
\subsection{\bf Variable Definitions and Expressions ({\tt /LET}\index{/LET} and
{\tt /BEG}\index{/BEG} )}
\begin{itemize}
\item Definitions are specified in the form: \\
\fbox{\tt /LET VariableName=expression}
\item Variable definitions and expressions begin on a single line with a {\tt /LET} command that is terminated by a carriage return.
Long entries will be line-wrapped by the editor and may appear to extend past one
line on the display. The line continuation symbol (\verb"\" followed by a carriage return)
can be used to break a long line into several lines and still be considered as
a single long line.
\item {\tt /BEG} is simply an alias for {\tt /LET}, and is used to indicate the beginning of each problem in the
following manner: \\
\fbox{{\tt /BEG prob\_val=3}}. \\
This sets the variable prob\_val which can
then be used to define the weight of the problem in the {\tt /ANS} specification the signals the end of the
problem.
\item The \capa\ system does reserve variable names for certain
functions used in the system. They are listed in the {\bf Intrinsic Functions
Table}, and must not be used as variable names.
\normalsize
\item {\bf List of Available Expressions}:
\begin{tabbing}
1234567890123456789012345\= 12345678901234567890 \= \kill
{\it Integer} \> $\diamond $ An integer. \\
{\it Real number} \> $\diamond $ A real number. It could be of the form
\\{\it $$ } \> $$
123.4, 1.234E+2, 1.234E+2, 1.234E+02, 1.234e+02. \\
{\it ``string''} \> $\diamond $ A string. It is specified in the
form \verb+"A block of text"+. \\
% \> Quotes may be imbedded in string by prefixing them
% with a `\verb"\\"'. \\
{\it Variable Name} \> $\diamond $ A variable previously defined. \\
{\it ( expression )} \> $\diamond $ Precedence, evaluate {\it expression}
first. \\
{\it - expression } \> $\diamond $ Negative of {\it expression}. \\
{\it function([expression, $\cdots$]) } \> $\diamond $ Call a function with
arguments. (see below) \\
{\it expression $*$ expression } \> $\diamond $ Multiply expressions. \\
{\it expression $/$ expression } \> $\diamond $ Divide expresssions. \\
{\it expression $+$ expression } \> $\diamond $ Add expressions, concatenate
strings \\
{\it expression $-$ expression } \> $\diamond $ Subtract expressions. \\
{\it expression $==$ expression } \> $\diamond $ Logical; expressions equal?
Returns 0 {\small if false}, 1
{\small if true}\\
{\it expression $!=$ expression } \> $\diamond $ Logical; expressions
different? Returns 0 or 1\\
{\it expression $>=$ expression } \> $\diamond $ Logical; greater than or
equal? Returns 0 or 1\\
{\it expression $<=$ expression } \> $\diamond $ Logical; less than or equal?
Returns 0 or 1\\
{\it expression $>$ expression } \> $\diamond $ Logical; greater than? Returns
0 or 1\\
{\it expression $<$ expression } \> $\diamond $ Logical; smaller than? Returns
0 or 1\\
\end{tabbing}
\item There are three types of variables: integer, real and string. The type
is not explicitly specified but rather is assigned by context at the time the
variable is defined.
\item {\bf Note:} If you define a variable with an equation consisting
of only integer numbers, then the resulting answer will be an integer.
For example, we have the following code: \\
\fbox{\tt /LET variable1=1/2} \\
\fbox{\tt /LET variable2=35/12} \\
Then {\em variable1} will be assigned the value of ``0'' and {\em variable2} will be assigned the value of ``2''.
On the other hand, \\
\fbox{\tt /LET variable1=1.0/2.0} \\
will now be assigned the value of 0.5 because at least one real number was used
in the equation.
\item The variable names must begin with a letter but may contain letters,
numbers, and underline characters.
\item Variable names (and function names) {\bf are case sensitive}, and
there is no limit on the length of a variable name.
\item Variables must be defined before they are used in any other expression.
\normalsize
\item {\bf Note:} Quotation marks indicate the beginning and end of strings. You must use a
backslash to display the quotation marks within a string. For example: \\
\fbox{\tt /LET string= ``I'll be back.'' } \\
will produce
the ouput ``I'll be back.''
\item An expression may be be broken down into
several lines using the line continuation character \verb"\" followed
\underline{immediately} by a carriage return. This can help improve the legibility
of the code. Do not use the line continuation character \verb"\"
within a command, variable, or function name.
\begin{capacode}
/LET a_long_line = "This is a very, very, very long statement. It is convenient to \
divide it into two lines."
\end{capacode}
\item Once defined, the same variable can be used at any subsequent point in
the entire problem set or alternatively it could be be redefined.
\end{itemize}
\subsection{\bf Display of Variables \index{/DIS}( {\tt /DIS} )}
\begin{itemize}
\item The {\em value} of a previously defined variable can be displayed in the displayed text
by placing the variable name in the {\tt /DIS()} command,
e.g. {\tt/DIS(}{\em variable}{\tt )}.
\item The format of the display of a numerical value can be controlled
using a colon and a format specification. For example, {\tt /DIS(LENGTH:3f)} means
display the variable {\em LENGTH} as a floating point number with three places
\underline{after} the decimal ({\em x}.{\em xxx}). {\tt /DIS(LENGTH:2E)} will
display the variable in scientific notation with two decimal places
({\em x}.{\em xx}{\tt E}{\em x}). The colon is a delimiter indicating that
a format specification follows.
\item {\sf Quizzer} shows a default line length of 80 characters. In the x-windows version, a greater line length can be obtained by resizing the window,
accomplished by dragging the lower right corner.
\item {\tt /DIS(\index{stdline}stdline)} will display a short line that is used to
seperate problems. When you build sets
with {\sf Quizzer} using import, you have the option of displaying a ``standard line'' or a
{\tt webonlyline} (a line that appears on the web only) after the problem. When printing two sided,
you have the option of diplaying a {\tt stdlineOvr} which displays the word "Over" so students realize
that the set is two sided. All of these variables are defined in the {\sl /demolibrary/Tools/StdMacros} file.
\item {\bf Note:} A total of 37 lines are available for telnet display for each question on the VT100 terminal.
These lines are separated onto two pages
with 20 lines available on the first page and 17 available on the second. Three lines are repeated for reading
consistency. Hints and explanations are displayed on separate screens, each of which can have up to 20 lines. There are no line limitations on the printed
or Web versions of the text.
\end{itemize}
%\item
\subsection{\bf The Import Function ( \index{/IMP}{\tt /IMP} )}
\begin{itemize}
\item The {\tt /IMP} function calls and uses the contents of the
specified file, however the file's content is not displayed in the {\sl set$x$.qz}
file.
\item The /IMP command requires a string input, either the string
filename or a variable which provides the string filename.
\begin{enumerate}
\item For example:
\\ \fbox{\tt /IMP "HWTop"} \\
will import the {\sl HWTop} file from the local directory.
\item For files in other
directories, use either relative or absolute paths as part of the filename,
such as: \\
\fbox{\tt /IMP "/demolibrary/Tools/StdMacros"} \\
or: \\
\fbox{\tt /IMP "../mystuff"}. \\
{\bf Note} that if relative paths are used, the {\tt /IMP} command will not work unless it
is the appropriate directory and can cause errors if the file is moved.
\item The file may be selected
dynamically
from a set, for example,
\begin{capacode}
/LET integer=random(1,10,1)
/LET filename="File"+integer
/IMP filename
\end{capacode}
which will import a randomly selected {\sl File$x$} from {\sl File1, File2, ...File10}.
\end{enumerate}
{\bf Note:} Adding an integer to a string results in a concatenated
newstring. This can be used to provide even greater variety among
sets for students, since different problems or graphics on a given topic can be selected.
This feature may be especially useful for producing standardized tests.
With a large
enough problem base, students can be given a randomly selected set to prepare
for the test.
\end{itemize}
\subsection{\bf Comment Lines (\index{//} {\tt //} )}
\begin{itemize}
\item Comments are any character strings after a double forward
slash, ({\tt //}).
For example:
\begin{capacode}
//A line of comments
//You can also put comments after code.
/LET number=random(1,4,1) // chooses a random number
\end{capacode}
\item The comments are only displayed by the {\sf Quizzer} module and are for
the benefit of the persons writing and reviewing the actual problem code.
\item Instructors are strongly encouraged to include comment lines in order to
indicate authorship and to describe the structure of the problems for future use.
\end{itemize}
\subsection{\bf Hints (\index{/HIN} {\tt /HIN} )}
\begin{itemize}
\item Hints are optional. There can only be one hint per problem.
The hint becomes available after a wrong answer is entered by the student.
The answer function has reserved syntax for changing the number of entries before displaying the hint. The notation {\tt /ANS(variable:2f, hint=6)}
would require that a student enter 6 incorrect answers hefore being presented with the hint.
\item The text for hints contain character strings (no expressions) and can
display string variables defined before the hint to match a problems content,
and is specified as:
\begin{capacode}
/LET index=random(1,4)
/LET pronoun=choose(index,"he","she","she","he")
/LET ppronoun=choose(index,"his","her","her","his")
/LET person=choose(index,"son","daughter","niece","nephew")
/HIN While her /DIS(person) was being picked up, /DIS(pronoun)
/HIN accidently let /DIS(ppronoun) balloon escape.
\end{capacode}
\normalsize
\item This hint has two lines and two carriage returns. The contents of both
lines are displayed simultaneously; it is not two separate hints.
\item Content of all lines typed with a {\tt /HIN} at the
beginning are displayed as the hint. The relative ordering of the hint lines is
preserved, and the hint is displayed as a separate page on the
VT100 screen and below the answer box on the web version.
\item Only one {\tt /HIN} is needed if the text is very long and uses the continuation character.
\begin{capacode}
/HIN A hint is often welcomed by students. It sometimes requires \
a large amount of text and might require several lines.
\end{capacode}
Or (no carriage return at all, line wraps automatically):
\begin{capacode}
/HIN A hint is often welcomed by students. It sometimes requires a large amount of text and
might require several lines.
\end{capacode}
\item Hints can also be viewed after a problem set's due date.
\end{itemize}
\subsection{\bf Explanations (\index{/EXP} {\tt /EXP} )}
\begin{itemize}
\item Lines of explanations begin with the {\tt /EXP} characters and are
displayed on the login-terminal only when requested after a problem set is
closed. The VT100 display offers the option to view a separate page containing
the explanation. The web version automatically displays the coded explanation
when the student views a closed problem set.
\item The syntax for coding explanations is very similar to hints. It is
useful to include a detailed explanation for some problems.
Students often review old problem sets at exam time and may not exactly
remember how to solve a specific problem.
\item The following are explanation examples:
\begin{capacode}
/EXP An explanation is often welcomed by students.
/EXP It sometimes requires a large amount of text
/EXP and might require several lines.
\end{capacode}
Or:
\begin{capacode}
/EXP An explanation is often welcomed by students. It sometimes requires \
a large amount of text and might require several lines.
\end{capacode}
Or (no carriage return at all, line wrap automatic):
\begin{capacode}
/EXP An explanation is often welcomed by students. It sometimes requires a large amount of
text and might require several lines.
\end{capacode}
\end{itemize}
%\item
\subsection{\bf The Mapping Function ( \index{/MAP}{\tt /MAP} and \index{/RMAP}
{\tt /RMAP} )}
\begin{itemize}
\item The {\tt /MAP} function is used to map and permute the assigned values
from a set of variables onto another set of variables according to a given
seed value.
\item For example:
\begin{capacode}
/LET seed=random(1,3000,1)
/MAP(seed;M1,M2,M3;m,n,o)
\end{capacode}
Assigns to the variables $M1$, $M2$, and $M3$ the values of the variables $m$, $n$, and $o$.
The correspondence (i.e. which of $m$, $n$, or $o$ is assigned to $M1$, etc....) is
determined by the value of the variable `seed', which in this example is
selected from 1 to 300.
\item The arguments of the {\tt /MAP} function are divided into three portions
by a semicolon symbol (the seed, the variable set, and the defined variable
set). The value of the seed is used to setup a random number generator
which is needed to
select one value from the {\bf second} set of variables and assign it to one of the
variables in the {\tt first} set. In the above example, two random numbers will
be generated.
The first random number is then divided by three and the remainder is used to
determine the first value to be selected from the set of three values and
gets assigned to the first variable in the list. The second random number
is then divided by two and the remainder is used to determine the second
value from the remaining two values and
is mapped to the second variable. The very last value left is then
assigned to the last variable. Therefore, the number of variables in both sets
must be equal. If any of the variables that appear in the second variable set
were not previously assigned a value, a warning will be issued. Variables used in the
first variable set may contain no data at first, but all variables in the first
variable set will
receive some value after the {\tt /MAP} function is called.
\item The {\tt /MAP} function is used in all the auxiliary files of the multiple
choice templates prepared to facilitate coding of qualitative or conceptual
questions.
\item The {\tt /RMAP} function does the reverse action of the {\tt /MAP} function.
The value of the seed is used to setup a random number generator
which is needed to
select one variable from the {\bf first} set of variables and map it with one of the
values from the {\tt first} set.
For example, we have the following code:
\begin{capacode}
/LET seed=random(1,300,1)
/LET w=1
/LET x=2
/LET y=3
/LET z=4
/MAP(seed;a,b,c,d;w,x,y,z)
/DIS(a), /DIS(b), /DIS(c), /DIS(d)
output: 3, 1, 2, 4
\end{capacode}
The values of the the second set of variables were randomly assigned (dependent
on the seed value) to the first set variables.
See how the {\bf value} of {\em w} (the first of the four values in its value set) is
mapped to the {\bf variable} {\em b} (the second of the variables in its set).
If we used {\tt /RMAP} instead with
the same seed value used above in the code below, the resulting mapping is reversed.
Notice how the {\bf variable} {\em a} (the first of the four variables in its set) has the
{\bf value} of {\em x} (the second of the four values) mapped to it.
\begin{capacode}
/LET w=1
/LET x=2
/LET y=3
/LET z=4
/RMAP(seed;a,b,c,d;w,x,y,z)
/DIS(a), /DIS(b), /DIS(c), /DIS(d)
output: 2, 3, 1, 4
\end{capacode}
Therefore, {\tt /RMAP} can also be used to unscramble {\tt /MAP}:
\begin{capacode}
/LET seed=random(1,300,1)
/LET w=1
/LET x=2
/LET y=3
/LET z=4
/MAP(seed;a,b,c,d;w,x,y,z) //same seed as above - not redefined
/RMAP(seed;p,q,r,s;a,b,c,d)
/DIS(p), /DIS(q), /DIS(r), /DIS(s)
output: 1, 2, 3, 4
\end{capacode}
\item To view an example of both the {\tt /MAP} and {\tt /RMAP} see the second
problem in {\sl set19.qz} from the {\sl nsc121s9} class directory({\sl /demolibrary/type-other/OR-MAP-RMAP}).
\end{itemize}
\subsection{\bf Conditional Statements ( \index{/IF}{\tt /IF}, \index{/ELSE}{\tt /ELSE},
and \index{/ENDIF}{\tt /ENDIF} )}
\begin{itemize}
\item {\tt /IF}, {\tt /ELSE}, and {\tt /ENDIF} are used to add conditions within the \capa\
coding.
\item For example:
\begin{capacode}
//NOTE: Each /IF needs an /ENDIF
/LET choice=random(1,4,1)
/IF (choice==1)
If the statement within the parentheses is true, this text
will be printed for the student to read.
/ELSE
/IF (choice==2)
This line will be printed instead.
/ELSE
/IF (choice==3)
This line will be printed.
/ELSE
If all the conditions above are false, then this text
will be printed.
/ENDIF //ends the last /IF condition
/ENDIF //ends the second /IF condition
/ENDIF //ends the first /IF condition
\end{capacode}
\item Other commands can be entered in the {\tt /IF} statement. For example,
you may have the following:
\begin{capacode}
/IF (choice!=1)
/ANS(5)
/ELSE
/ANS(0)
/ENDIF
\end{capacode}
Therefore, if the variable choice happens to {\bf not} equal the interger 1 then the
the answer is 5, otherwise the answer is 0. \\
\end{itemize}
\subsection{\bf Loops ( \index{/WHILE}{\tt /WHILE} and \index{/ENDWHILE}{\tt /ENDWHILE} )}
\begin{itemize}
\item Below is an example of the {\tt /WHILE} and {\tt /ENDWHILE} commands:
\begin{capacode}
Written below are the multiples of 5 up to 12:
/LET integer=0
/WHILE (integer <= 12)
/LET answer = 5*integer
/DIS(integer) * 5 = /DIS(answer) /DIS(web("","//",""))
//see the functions table to see how web() works
/LET integer=integer+1
/ENDWHILE
The output will display:
Written below are the multiples of 5 up to 12:
0 * 5 = 0
1 * 5 = 5
2 * 5 = 10
3 * 5 = 15
4 * 5 = 20
5 * 5 = 25
6 * 5 = 30
7 * 5 = 35
8 * 5 = 40
9 * 5 = 45
10 * 5 = 50
11 * 5 = 55
12 * 5 = 60
\end{capacode}
As long as the condition in the parentheses is true, the code between
the {\tt /WHILE} and {\tt /ENDWHILE} will be processed. When the condition
(in this case, the value of the variable {\em integer} is less than or equal
to 12) is false, control passes to the next line below the {\tt /ENDWHILE}.
\item Every {\tt /WHILE} was must have a {\tt /ENDWHILE} to mark the end of the {\tt /WHILE} loop. \\
\end{itemize}
\subsection{\bf Answers (\index{/ANS()} {\tt /ANS} )}
\begin{itemize}
\item Each individual problem must be ended by an expression specifying the
answer. This answer expression consists of the keyword {\tt /ANS()}
starting on a new line.
\item The
answers are indicated specifically by the {\tt /ANS()} command, with the
parentheses containing the answer and the attributes of the answer.
The answers to problems can be previously defined variables.
There must be at least a variable, integer, real number, of string defining the answer within
the parentheses, ({\tt /ANS(variable), /ANS(5)}, etc.).
\item Several options are available to format the answer.
The attributes of the {\tt /ANS()} function are {\bf case insensitive}.
The available options for defining {\tt /ANS()} attributes are:
%**********************************************
\item {\bf List of Available Expressions:}
\begin{tabbing}
12345678901234567890123456789\= 12345678901234567890 \= \kill
{\tt wgt=} \> $\diamond $ problem weight \\
{\tt tries=} {\em or} {\tt try=} \> $\diamond $ number of allowed tries to input the answer\\
{\tt tol=} \> $\diamond $ answer tolerance \\
{\tt calc=fmt/unfmt} \> $\diamond $ sets tolerance to be calculated
from the \\
$$ \> $ $ \ formatted or unformatted answer. \\
{\tt sig=} \> $\diamond $ fixed number of significant digits. \\
{\tt sig=}{\em x} {\tt minus} {\em y} {\tt plus} {\em z}
\> $\diamond $ a range of significant digits from \\
$$ \> $ $ \ {\em x} minus {\em y} to {\em x} plus {\em z} \\
{\tt unit=} {\em or} {\tt units=} \> $\diamond $ units of answer (dimensions)\\
{\tt hint=} \> $\diamond $ number of wrong student entered
answers \\
$$ \> $ $ \ before the hint appears. \\
{\tt str=mc/cs/ci/fml} \> $\diamond $ different ways of accepting
a string answer \\
$$ \> $ $ \ with fml for math formula as answer. \\
{\tt hgr=on} \> $\diamond $ hand graded answer \\
{\tt pc=on} \> $\diamond $ partial credit \\
{\tt ansbox=on/off} \> $\diamond $ Web generated answer box \\
{\tt br=on/off} \> $\diamond $ Web line break \\
\end{tabbing}
\item {\bf More detailed explanations are found below:}
%**********************************************
\begin{enumerate}
%BEGIN DISCRIPTION OF ANSWER OPTIONS
%***********************************************PROBLEM WEIGHT
\item {\bf Problem Weight:\index{WGT=}} The problem point value (or weight)
is set by: \\
\fbox{\tt /ANS(variable, wgt=2)}\\
The problem value can
be an integer value between 0 and 9. A variable can be can be
defined at
the beginning of a problem by either of the following commands:
\\ \fbox{\tt /BEG prob\_val=3} \\
or \\
\fbox{\tt /LET prob\_val=3} \\
Then, this
value can be used in the {\tt /ANS()} function:\\
\fbox{\tt /ANS(variable, wgt=prob\_val, tries=20)}. \\
If the problem weight is not defined, the default value
of 1 point is used.
%******************************************TRIES
\item {\bf Tries:\index{TRY=}\index{TRIES=}} The number of attempts to enter an incorrect
answer can be limited to an integer value less than
or equal to 99.
\begin{itemize}
\item The format for setting the number of tries is: \\
\fbox{\tt /ANS(variable, tries=35)} \\
or \\
\fbox{\tt /ANS(variable, tries=try\_val)}
\item In the second example shown above, {\em try\_val} is assumed to be a previously defined
variable.
The student
receives a message near the answer field stating the number of
attempts and the total number of tries available for each
problem in which the {\tt tries=$x$} has been specified.
A warning message is displayed when only one try
remains.
Errors in either
significant figures or units will {\bf not} decrease the
number of remaining tries for the student. Both the
significant figure
and unit must be correct before
a ``Correct'' or ``Incorrect''
response to the numerical portion of the answer is given to
the student.
\item {\bf Note:} {\tt try=} is equivalent to {\tt tries=} \end{itemize}
%*********************************************TOLERANCE
\item {\bf Tolerance: \index{TOL=}}
The tolerance can be specified as (1) a numerical value, (2) as a percentage of the correct answer or as (3) a pre-defined variable.
\begin{enumerate}
\item The format for a set numerical value would be given by:\\
\fbox{\tt /ANS(variable:3f,tol=0.5)}
\item The format of a \% tolerance would be given by: \\
\fbox{\tt /ANS(variable:3f, tol=1.1\%)}. \\
This is specified if there is a possibility that the
answer will be calculated as equal to zero. The tolerance
is thus given a value rather than a percentage.
\item The format for a defined tolerance variable would be: \\
\fbox{\tt /ANS(variable:3f, tol=TolVar)}. \\
\item The format for a \% tolerance with a defined variable would be: \\
\fbox{\tt /ANS(variable:3f, tol=TolVar\%}
\end{enumerate}
{\em Note that the display of the answer can be formatted according to the same commands used
in /DIS.}
\begin{itemize}
\item {\bf Real answers:} A tolerance should be specified
for `real' answers. It can be
absolute or relative. An absolute tolerance can be a variable.
Answers with real values can be {\bf formatted} with
specifications {\tt :1E, :3E,
:2f,}
etc., where {\tt 1E} means exponential notation with one decimal place,
{\tt :3E} means exponential notation with three
decimal places, and {\tt :2f} means two floating decimals.
\begin{enumerate}
\item \fbox{\tt /ANS(variable:2E,tol=1.2\%,wgt=prob\_val,tries=try\_val)}
\\ When
an answer submitted by a student is within the relative
tolerance (1.2\% ) of the correct answer, the student receives
`correct'. {\bf Note:} The relative tolerances are based
on the {\bf unformatted} answer.
\item \fbox{\tt /ANS(variable:2E,tol=5.0,wgt=prob\_val,tries=try\_val)}
\\ An answer
submitted by a student within the absolute tolerance of 5.0,
would be graded `correct'. That is the answer must lie within the range {\em variable}-5
to {\em variable}+5.
\item \fbox{\tt /ANS(variable:3E,tol=tol\_val,wgt=prob\_val, tries=try\_val)} \\
Here the tolerance is a previously defined quantity,
{\tt tol\_val}.
\item {\tt calc=fmt/unfmt}: Selects the application of the
tolerance range for the formatted or unformatted numerical
answer value. For example, say we have {\tt variable=2/3} for the following answer line: \\
\fbox{\tt /ANS(variable:3f,tol=.01,wgt=prob\_val, tries=try\_val)} \\
the error would be between two-thirds plus or minus .01. If we used this instead though: \\
\fbox{\tt /ANS(variable:3f,tol=.01,calc=fmt,wgt=prob\_val,tries=try\_val)} \\
the error would be between 0.667 plus or minus 0.01. The default value is unformatted.
\end{enumerate}
\item {\bf Integer answers:} You may not want a tolerance for an
integer answer. \\
\fbox{\tt /LET variable=34}
\begin{enumerate}
\item \fbox{\tt /ANS(variable, tol=0, wgt=prob\_val,tries=try\_val, hint=hint\_val)}\\
Only the number ``34'' will be
accepted as correct.
\item \fbox{\tt /ANS(variable, wgt=prob\_val, tries=try\_val, hint=hint\_val)}\\
Same as above. Only the number ``34'' will be accepted as
correct.
\item You can also use a percentage tolerance or a non-integer real
number as a tolerance, but then students can get a ``correct'' answer
by entering in an appropriate non-integer number. For example: \\ \fbox{\tt /ANS(variable, tol=4, wgt=prob\_val, tries=try\_val, hint=hint\_val)}
\\ Any answer within plus or
minus 4 units is accepted as correct. For example, the
real number, 36.5 will be accepted as ``correct''.
\end{enumerate}
\item {\bf Note:} If you define your answer variable with an equation consisting
of only integer numbers, then the resulting answer will be an integer.
For example, we have the following code: \\
\fbox{\tt /LET variable1=1/2} \\
\fbox{\tt /LET variable2=35/12} \\
Then {\em variable1} will be assigned the value of ``0'' and {\em variable2} will be assigned the value of ``2''. On the other hand, \\
\fbox{\tt /LET variable1=1.0/2.0} \\
will now be assigned the value of 0.5 because at least one real number was used
in the equation.
\footnote{You may have noticed this text from the /LET section, but it is worth repeating because it can be
a major source of frustration to the instructor and students if real numbers and integer numbers are not
dealt with correctly.}
\end{itemize}
%************************************************SIGNIFICANT FIGURES
\item {\bf Significant Figures:\index{SIG=}}
If unspecified, significant figures are not checked and
any number of significant figures between 1 and 15 are
accepted provided the answer entered falls within the
specified numerical tolerance range. The number of acceptable
significant figures can be specified by the following format:
\begin{enumerate}
\item \fbox{\tt /ANS(variable, sig=4 plus 1 minus 1, tries=try\_val, wgt=prob\_val, hint=hint\_val)} \\
This will accept 3, 4, or 5 significant figures in the answer.
\item \fbox{\tt /ANS(variable, sig=3 plus 2, tries=try\_val, wgt=prob\_val, hint=hint\_val)} \\
This will accept 3, 4, or 5 significant figures in the answer.
\item \fbox{\tt /ANS(variable, sig=4 , tries=try\_val, wgt=prob\_val, hint=hint\_val)} \\
This will only accept 4 significant figures in the answer.
\end{enumerate}
Care must be exercised when limiting the significant figures
when a percentage tolerance is used. It is possible to create a situation where the student cannot enter a correct answer for a problem. For example, the server might calculate the unformatted {\em variable} to be equal to 0.409. The following answer format will create such a situation: \\
\fbox{\tt /ANS(variable:0f, sig=1, tol=1\%, wgt=prob\_val)} \\
The student will calculate this answer to be 4E-1 which is not within 1\% of the
answer.
%********************************************UNITS
\item {\bf Units:\index{unit=}} A file in the class
directory named {\sl capa.config} lists all SI units and other
user defined acceptable units with
their relationships.
That file can be edited by the instructor.
Units are entered as strings.
\begin{itemize}
\item A typical format for
answers requiring a unit is: \\
\fbox{\tt /ANS(perimeter:3f,unit="cm",sig=4)}\\
or\\
\fbox{\tt /ANS(area:2f,unit="cm\^{}2")}
\item For a specially defined unit, one can use a variable, e.g.
\begin{capacode} /LET StringVar="dollar"
/ANS(cost:2f,unit=StringVar,tol=.005,wgt=2,tries=6,sig=4 plus 3)
\end{capacode}
\item {\sl /demolibrary/type03/msu-prob22.txt} and
{\sl /demolibrary/type03/msu-prob23.txt} \\ are two problems
included in the distribution
package which aid in teaching students the rules for entering
answers with units in a \capa\ session. These are useful for students in an initial \capa\ set.
\item {\bf Note:} {\tt units=} is equivalent to {\tt unit=}
\end{itemize}
%************************************************SHOW HINTS
\item {\bf Show Hints:\index{hint=}} The hint can be configured so that it
is available or displayed only after a certain number of tries.
This is achieved by setting {\tt hint=AnInteger} (e.g. {\tt hint=3})
in the answer format.
For example: \\
\fbox{\tt /ANS(variable, hint=3, tries=10, wgt=1)} \\
or \\
\fbox{\tt /ANS(variable, hint=hint\_val, tries=10, wgt=1)}\\
will both
(1) show the hint on a Web browser after 3 tries
and (2) allow it to be viewed on telnet after 3 or more tries
by entering :H which shows up on the menu lines.
%***********************************************STRING ANSWERS
\item {\bf String answers} can be exact comparisons, or have the order
and/or case disregarded.
\begin{enumerate}
\item \fbox{\tt /ANS(letters,str=ci,wgt=prob\_val,tries=20)} \\
{The command {\tt str=ci} is the default value, the order is checked but case insensitive.}
\item \fbox{\tt /ANS("KCl",wgt=prob\_val,tries=20)}\\
{ The default is case insensitive. Therefore, answers such as ``kcl'' and
``KcL'' are accepted as correct.}
\item \fbox{\tt /ANS(letters,wgt=prob\_val,tries=20)}\\
{ {\em letters} is a string variable previously defined. This works
like the example above. (The order is essential, but
not case sensitive.)}
\item \fbox{\tt /ANS(letters,str=mc,wgt=prob\_val,tries=20)}\\
{The command
{\tt str=mc} accepts any order of the correct responses.
Hence, ``abc'' and ``acb'' are equivalent.}
\item \fbox{\tt /ANS(letters,str=cs,wgt=prob\_val,tries=20)} \\
{This is an exact string comparison. Both the order and
the case are required.}
\item {\bf Formula as string answer:}
\begin{capacode}
/ANS(fm1,str=fml,eval=<"x" @ pt1:pt2#20>,TOL=1E-3, tries=try_val,
wgt=prob_val,hint=hint_val) \end{capacode}
In this one-variable case, \capa\ will sample the student's input formula and the formula fm1, the string formula representing the correct answer. Comparison will be at 20 values of x between x = pt1 and x = pt2). All comparisons must fall with the tolerance, here 1E-3, for a correct answer.\\
{\em For examples, see the templates: \\{\tt /demolibrary/MCTools/equationA} and {\tt /demolibrary/MCTools/equationXY} }
\end{enumerate}
%********************************************HAND GRADING
\item {\bf Hand Grading:\index{hgr=}} A problem can be designated to be hand
graded. For this case students are not allowed to answer
via telnet or web sessions and the question is graded by the instructor using the {\sf Grader} application.
The format for this is: \\
{\tt /ANS(variable,hgr=on, tries=1, wgt=1)} \\
{\em (See /SUBJECTIVE for telnet or
Web submitted essay questions for hand grading.)}
%*******************************************PARTIAL CREDIT
\item {\bf Partial Credit:\index{pcr=}} A multiple point problem can be
specified to have partial credit. This attribute works like
{\tt hgr=on} in that students cannot login to
answer the question. The format for this is: \\
\fbox{\tt /ANS(variable, wgt=9, pcr=on, tries=1)}\\
This allows an instructor to
manually enter an integer point value from 0 to 9 through the
{\sf Grader} application.
%**********************************************MISCELLANEOUS ANSWER ATTRIBUTES
\item {\bf Miscellaneous Answer Attributes}
\begin{enumerate}
\item {\tt br=on/off}: This starts/stops the generation of
$<$br$>$ (a line break) on the Web display. The default value is on.
\item {\tt ansbox=on/off}: Controls the generation and display
of the answer box for the Web. The default value is on.
\item {\tt Yes/no} is equivalent to {\tt on/off}.
\end{enumerate}
%*******************************************END OF ANSWER ATTRIBUTES
\end{enumerate}
\end{itemize}
\subsection{\bf Multiple Answers ( \index{/AND}\index{/OR}{\tt /AND} and {\tt /OR} )}
\begin{itemize}
\item {\tt /AND} or {\tt /OR} after an answer specification requires another {\tt /ANS} statement be present.
In the case of {\tt /AND}, two successive answers will be required from the student. In the case of {\tt /OR},
the student will receive credit if either answer is supplied.
\item Below is an example for {\tt /AND}:
\begin{capacode}
/ANS(variable_1, wgt=prob_val, tries=try_value)
/AND
/ANS(variable_2, wgt=prob_val, tries=try_value)
\end{capacode}
The above example requires two answers from the student.
During a telnet session the student will be prompted to enter the first
answer and then the second {\bf in the order that they are coded}.
During a web session, there will be multiple answer boxes labeled ``Answer 1''
and so on. Again, they must be entered in order by the student. It is
recommended that the problem text give instructions to the student to answer the questions in order.
Note that the problem is worth the number of points of the last defined {\tt wgt} specification, i.e. if in the
first answer {\tt wgt=3} and in the second answer {\tt wgt=1}, the student will only receive one point for
the total question.
\item Below is an example for {\tt /OR}:
\begin{capacode}
/ANS(variable_1, wgt=prob_val, tries=try_value)
/OR
/ANS(variable_2, wgt=prob_val, tries=try_value)
\end{capacode}
The {\tt /OR} is suitable for questions such as asking the student to choose one
of the correct answers from a list.
\item Note that the variable {\em try\_val} was used in the examples above
to simplify the script. If the number of tries is different within the answer
specifications, the last defined
number of tries is given to the student for their amount of tries in that
problem.
\end{itemize}
\subsection{\bf Essay Questions (\index{/SUBJECTIVE} {\tt /SUBJECTIVE} )}
{\tt /SUBJECTIVE} is used instead of {\tt /ANS} when the instructor wants to allow students
to submit a short essay.
The student can type their essay in either
the telnet or web session. The instructor grades this essay with the
{\sf Grader} application and the score is recorded in the database.
{\tt hgr=on} must be specified when using {\tt /SUBJECTIVE}.
\begin{capacode} /SUBJECTIVE(wgt=prob_val, hgr=on, tries=try_val)
\end{capacode}
You may choose to set a number of tries also. The student will be allowed to rewrite their essay according
to the number of tries that the instructor allows.
\subsection{\bf Displaying text verbatim (\index{/VERB} \index{/ENDVERB} {\tt /VERB} and {\tt /ENDVERB} )}
Used to display text verbatim:
\begin{capacode}
Enter the answer as in a calculator:
/VERB
Example: 4.567 + 2.431 * x^4 - 0.310 * x^2
/ENDVERB
\end{capacode}
\subsection{\bf Displaying Information Before the Problem Set (\index{/START} {\tt /START} )}
All the material coded before {\tt /START} in a {\sl set$x$.qz} file is both printed
out and displayed on the Web for students to see. See {\sl set19.qz} in the
{\sl nsc121s9} class directory for an example (note the placement of the imported {\sl HWTop} file).
\subsection{\bf Ending the Problem Set ( \index{/END}{\tt /END} )}
\begin{itemize}
\item {\tt /END()} or {\tt /END(\index{stdendline}stdendline)} causes the parser to stop and ignore all input
characters beyond that command. String variables can be defined and constructed and additional text
(such as instructions for students) may be displayed between the last {\tt /ANS()} and
{\tt /END}.
\item All sets should include {\tt /END(stdendline)}, so that both on
paper and on the Web, the department is identified and the
copyright nature of the \capa\ software is indicated. The string for
{\tt stdendline} is created in the {\sl HWTop} file in the class directory and can be
edited by users, such as changing the Dept. ID for your particular class.
\item The \capa\ system counts the number of problems in a problem set by
counting the number of {\bf proper} answer lines (lines containing {\tt /ANS} or {\tt /SUBJECTIVE}). If there is
an error in coding and the answer cannot be evaluated, that problem is not
counted by {\sf Quizzer}.
\end{itemize}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{\small
\begin{center}\begin{tabular}{|p{2.9cm}|p{14.2cm}|} \hline
\multicolumn{2}{|c|}{\bf Table of Intrinsic Functions: Names Are Case
Sensitive.}\\ \hline
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{ Functions}& Description, Sample quizzer input and output for printing \\ \hline
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\index{sin()}\index{cos()}\index{tan()}{\tt sin(x), cos(x), tan(x)}& Trigonometric functions. x is in radians.
\begin{verbatim}/LET angle=60.0
/LET var1=sin(angle*3.141592654/180)
Sine of /DIS(angle:1f) degrees is /DIS(var1:3f).
\end{verbatim}
Output: {\tt Sine of 60.0 degrees is 0.866. }\\ \hline
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\index{asin()}\index{acos()}\index{atan()}\index{atan2()}{\tt asin(x), acos(x), atan(x), atan2(y,x)}& Inverse trigonometric functions. Returns
radians. asin() computes the principal value of the arc sine of x, in the
interval [-pi/2,pi/2] radians. The value of x must be in the domain [-1,1].
acos() computes the principal value of the arc cosine of x, in
the interval [0,pi] radians. The value of x must be in the domain [-1,1].
atan2() computes the principal value of the arc tangent of y/x,
in the interval [-pi,pi] radians. The sign of atan2() is
determined by the sign of y.
\begin{verbatim}/IMP "demolibrary/Tools/StdConst"
//pi_c is a variable set to equal pi and is found in the imported file above.
/LET var1=-1.65
/LET var2r=atan(var1)
/LET var3d=atan(var1)*180.0/PI
The angle whose tangent is /DIS(var1:3f) can be expressed
as /DIS(var2r:3E) radians or as /DIS(var3d:3E) degrees.
\end{verbatim}
Output for telnet session:
{\tt The angle whose tangent is -1.650 can be expressed
as -1.026E+00 radians or as -5.878E+01 degrees.}
\\ \hline
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\index{log()}\index{log10()}{\tt log(x), log10(x)}& Natural logarithm and base-10 logarithm. Note that the
the variables {\tt natlog} and {\tt tenlog} were defined to simplify the coding
of this problem by allowing complicated text (with subscripts and superscripts)
to be printed by displaying a variable.
\begin{verbatim}
/LET natlog=tex("$log_e$","log_e")
/LET tenlog=tex("$log_{10}$","log_10")
/LET x=2546.7
/LET var1=log(x)
/LET var2=log10(x)
/LET ratio=var1/var2
/LET var3=log(10.0)
The /DIS(natlog) of /DIS(x:1f) is /DIS(var1:3E) while its /DIS(tenlog)
is /DIS(var2:3E). Note that the ratio /DIS(natlog)//DIS(tenlog)
= /DIS(ratio:3f), which is just /DIS(natlog)(10), i.e. /DIS(var3:3E).
\end{verbatim}
Output for print out or Web:
The $log_e$ of 2546.7 is $7.843$ while its
$log_{10}$
is $3.406$. Note that the ratio $log_e$/$log_{10}$
= 2.303, which is just $log_e$(10), i.e. $2.303$.
\\ \hline
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\index{exp()}\index{pow()}\index{sqrt()}{\tt exp(x), pow(x,y), sqrt(x)}& Exponential, power, and square root.
Compute $e^x$, $x^y$, and $\sqrt{x}$ respectively.
\begin{verbatim}/LET varx=1.526
/LET vary=0.5
/LET var1=exp(varx)
/LET var2=pow(varx,0.5)
/LET var3=pow(varx,vary)
/LET var4=sqrt(varx)
var1=/DIS(var1:2f); var2=/DIS(var2:2f); var3=/DIS(var3:2f);
var4=/DIS(var4:2f).
\end{verbatim}
Output: {\tt var1 = 4.60; var2 = 1.24; var3 = 1.24; var4 =
1.24.}
\\ \hline
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{tabular}\end{center}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{\small
\begin{center}\begin{tabular}{|p{2.9cm}|p{14.2cm}|} \hline
{ Functions}& Description, sample quizzer code and output \\ \hline
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\index{abs()}\index{sgn()}{\tt abs(x), sgn(x)}& {\tt abs(x)} returns the absolute value of $x$.
{\tt sgn(x)} returns $1$, $0$ or $-1$ depending on value
of $x$
\begin{verbatim}/LET xx=-2.5
/LET var1=abs(-4.5)
/LET var2=sgn(xx)
/LET var3=sgn(-4.5*xx)
var1=/DIS(var1:2f) var2=/DIS(var2) var2=/DIS(var2:2f) var3=/DIS(var3)
\end{verbatim}
Output: {\tt var1=4.50 var2=-1 var2=-1.00 var3=1
}\\ \hline
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\index{erf()}\index{erfc()}{\tt erf(x), erfc(x)}& Error functions. ${erf}(x) = \frac{2}{\sqrt{\pi}}
\int_0^{x} e^{-t^2} dt$ and
${erfc}(x) = 1.0 - {erf}(x)$.
\begin{verbatim}/LET varx=0.51
Evaluate the Normal Probability Integral from -/DIS(varx)
to /DIS(varx). /DIS(newline)
/LET prob = erf(varx/sqrt(2.0))
Probability = /DIS(prob:4f)
\end{verbatim}
Output: {\tt Evaluate the Normal Probability Integral from -0.51
to 0.51. }
\newline {\tt Probability = 0.3899}
\\ \hline
%$\mathrm{erfc}(x) = 1.0 - \mathrm{erf}(x)$.}\\ \hline
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\index{ceil()}\index{floor()}{\tt ceil(x), floor(x)}& Ceiling and floor functions.
${ceil}(x) = \lceil x \rceil$ and ${floor}(x) = \lfloor
%$\mathrm{ceil}(x) = \lceil x \rceil$ and $\mathrm{floor}(x) = \lfloor
x \rfloor$. The ceiling function returns an integer rounding x toward positive
infinity. The floor function rounds toward negative infinity.
\begin{verbatim}/LET varx=ceil(3.65)
/LET vary=floor(3.65)
/LET varz=ceil(-5.73)
/LET varw=floor(-5.73)
varx=/DIS(varx) vary=/DIS(vary) varz=/DIS(varz) varw=/DIS(varw)
\end{verbatim}
Output: {\tt varx=4 vary=3 varz=-5 varw=-6
}\\ \hline
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\index{min()}\index{max()}{\tt min(...), max(...)}& Minimum and maximum functions, with indefinite number
of arguments.
Arguments must be of either all integer or real type. String comparison are
such that $A < a$. In other words,
lower case letters have a higher value than upper case letters.
\begin{verbatim}/LET a=min(23,45,12,7,9)
/LET b=max(23.1,45.3,12.6,7.1,9.0)
/LET c=min("a","ae","aeg","Aeg")
/LET d=max("a","ae","aeg","Aeg")
a=/DIS(a:2f) b=/DIS(b:2f) c=/DIS(c) d=/DIS(d)
\end{verbatim}
Output: {\tt a=7 b=45.30 c=Aeg d=aeg
}\\ \hline
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{tabular}\end{center}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{\small
\begin{center}\begin{tabular}{|p{2.9cm}|p{14.2cm}|} \hline
{ Functions}& Description, sample quizzer code and output \\ \hline
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\index{factorial()}{\tt factorial(n)}& Arguments must be an integer. Returns an integer if n is or
smaller, else or real value.
\begin{verbatim}/LET number=factorial(6)
/DIS("6!=")/DIS(number)/DIS(newline)
/DIS("0!=")/DIS(factorial(0))/DIS(newline)
/LET number2=factorial(21)
/DIS("21!=")/DIS(number2:3E)/DIS(newline) \end{verbatim}
Output: {\tt
6!=720\newline
0!=1\newline
21!=$5.109 \times 10^{19}$
}\\ \hline
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\index{modulus operator, \%}
{\tt N\% M}& N and M are integers, and the remainder of the integer ratio is
returned.
\begin{verbatim}
/LET ratio = 98/5
/DIS("ratio=")/DIS(ratio)/DIS(newline)
/LET leftover=98%5
/DIS("remainder=")/DIS(leftover) \end{verbatim}
Output: {\tt
ratio=19\newline
remainder=3 }\\ \hline
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\index{hyperbolic functions}
{\tt sinh(x), cosh(x), tanh(x)} & Hyperbolic functions.\\ \hline
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\index{hyperbolic functions, inverse}
{\tt asinh(x), acosh(x), atanh(x)}& Inverse hyperbolic functions.\\ \hline
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\index{roundto()}
{\tt roundto(var1,n)} & Rounds the value of real variable `var1' to n places (fixed point notation).
\begin{verbatim}
/LET value=100.0/3.0
Initial value = /DIS(value:5f)/DIS(newline)
/LET value=roundto(value,2)
The new value is now /DIS(value:5f) and can be used as
/DIS(value:2f) with no rounding error. \end{verbatim}
Output: {\tt Initial value =
33.33333
The new value is now 33.33000 and can be used as 33.33 with no rounding
error.}\\ \hline
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\index{web()}{\tt web("a","b","c") or web(a,b,c) }& ASCII (a), tex(b) and html(c) strings or
variables displayed respectively.
\begin{verbatim}
Example: \verb+{/DIS(web("M2","M$_2$","M<sub>2</sub>")) }+
Output for telnet session: M2
Output for printout or Web: M$_2$
\end{verbatim}
\\ \hline
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\index{html()}{\tt html(a) or html("a")} & variable or string `a' parsed for Web browser only.
\begin{verbatim}
Example:
/DIS(html("<br><a href=/nsc121s9/Links/webPulley.html> Motion of Masses \
on a Pulley</a><p>"))
\end {verbatim}
Displays link "Motion of Masses on a Pulley"
\\ \hline
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{tabular}\end{center} }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{\small
\begin{center}\begin{tabular}{|p{2.9cm}|p{14.2cm}|} \hline
{ Functions}& Description, sample quizzer code and output \\ \hline
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{\tt \index{Bessel functions, jn() and yn()}jn(0,x), jn(1,x), jn(n,x)}& Bessel functions of the first kind, with orders
$0$, $1$ and $n$ respectively. Note that the first argument is integer, the
second real.
\begin{verbatim}/LET aa=jn(0,3.0)
/LET bb=jn(1,3.0)
/LET cc=jn(2,3.0)
aa=/DIS(aa:4f) bb=/DIS(bb:4f) cc=/DIS(cc:4f)
\end{verbatim}
Output: {\tt aa=-0.2601 bb=0.3391 cc=0.4861
}\\ \hline
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{\tt \index{yn()}yn(0,x), yn(1,x), yn(n,x)}& Bessel functions of the second kind, with
orders $0$, $1$ and $n$ respectively. Note that the first argument is integer,
the second real.
\begin{verbatim}/LET dd=yn(1,3.0)
dd=/DIS (dd:4f)
\end{verbatim}
Output: {\tt dd=0.3247
}\\ \hline
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{\tt \index{random()}random(l,u,d)}& Returns a uniformly distributed random number
between $l$ and $u$ with steps of $d$. Note that all
arguments must be the same type, integer or real. {\footnotesize [When real number are used, avoid having
the step size such that the highest value lands on "u" as different machines may have different representations and accuracy.]}
\begin{verbatim}/LET index=random(2,5,2) //returns integers 2 or 4
/LET value=random(2.3,5.15 ,0.2 ) //returns 2.3, 2.5, 2.7,...., 5.1
index=/DIS(index) value=/DIS(value:2f)
\end{verbatim}
Output: {\tt index=4 value=3.70
}\\ \hline
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\index{choose()}
{\tt choose(i,...)}& Choose the $i$th item in the argument list. Integer $i$
must be greater than zero and
it's maximum possible value must not exceed the number of arguments following
it.
\begin{verbatim}/LET indx=3
/LET realvar=choose(indx, 23.0,45.4,67.3) // will select 67.3
/LET intvar=choose(indx, 23,45,67) // will select 67
/LET stringvar=choose(indx,"No","Yes","Maybe") // will select "Maybe"
realvar=/DIS(realvar:2f) intvar=/DIS(intvar) stringvar=/DIS(stringvar)
\end{verbatim}
Output: {\tt realvar=67.30 intvar=67 stringvar=Maybe
}\\ \hline
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\index{tex()}
{\tt tex(a,b)}, {\tt tex("a","b")}& When in TeX mode, return the first argument
$a$, and return the second argument $b$ in enscript mode (ASCII).
\begin{verbatim}/DIS(tex("This, in the .tex file.","This, in the ASCII version."))
/LET A=33
/LET B=66
/DIS(tex(A,B))
\end{verbatim}
Tex Output: This, in the .tex file. 33
\\ \hline
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{\tt var\_in\_tex(a)}& Equivalent to {\tt tex("a","")}
\\ \hline
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{tabular}\end{center}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{\small
\begin{center}\begin{tabular}{|p{2.9cm}|p{14.2cm}|} \hline
{ Functions}& Description, sample quizzer code and output \\ \hline
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\index{to\_string()}{\tt to\_string(x)}, {\tt to\_string(x,y)}& If variable x is an integer,
to\_string(x) returns a string. If x
is real the format is given by y as follows:
\begin{verbatim}
/LET name1=to_string(34.56789)
/LET name2=to_string(34.56789, ".3E")
/LET name3=to_string(34.56789, ".3f")
No format is /DIS(name1), with ".3E" format is /DIS(name2),
and with ".3f" format is /DIS(name3)
\end{verbatim}
Output:
No format is 34.56789, with ".3E" format is 3.457E+01,
and with ".3f" format is 34.568
\\ \hline
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\index{capa\_id()}\index{class()}\index{section()}\index{set()}\index{problem()}
{\tt capa\_id(), class(), section(), set(), problem()}& The \capa\ ID number,
class name, section number, set number
and problem number respectively. Variables can be assigned to their current values
or they can be displayed directly as shown below.
\begin{verbatim}/LET capaIDval=capa_id()
Your CAPA ID is /DIS(capaIDval). /DIS(newline)
The class name entered at login is /DIS(class()). /DIS(newline)
Your section number is /DIS(section()). /DIS(newline)
This is part of problem set /DIS(set()). /DIS(newline)
The current problem number is /DIS(problem()). /DIS(newline)
Output:
Your CAPA ID is 8659.
The class name entered at login is nsc121s9.
Your section number is 1.
This is part of problem set 2.
The current problem number is 2.
\end{verbatim}
\\ \hline
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\index{name()}\index{student\_number()}{\tt name(), {\tt student\_number()}}& student name and student number. The
latter can be printed on quizzes when the student\_number is used for identification to
resolve ambiguities.\begin{verbatim}
/DIS(name()) /DIS(student_number())
\end{verbatim}
Output: Student, Jamie . A12345678
\\ \hline
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\index{open\_date()}\index{due\_date()}\index{answer\_date()}\index{due_day()}
{\tt open\_date(), due\_date(), answer\_date()}& Problem set open date, due
date, and answer date. \begin{verbatim}
/DIS(open_date()) /DIS(newline)
/DIS(due_date()) /DIS(newline)
/DIS(answer_date()) /DIS(newline)
/DIS(due_day()) /DIS(newline)
Output:
Mon, May 3, 1999 at 08:00. \newline
Thr, May 6, 1999 at 08:00. \newline
Fri, May 7, 1999 at 08:00. \newline
Thr, May 6, 1999.
\end{verbatim}
\\ \hline
%************************************
\end{tabular}\end{center}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{\small
\begin{center}\begin{tabular}{|p{2.9cm}|p{14.2cm}|} \hline
{ Functions}& Description, sample quizzer code and output \\ \hline
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\index{get\_seed()}\index{set\_seed()}{\tt get\_seed(), set\_seed()}
& get\_seed() returns the value of the seed for the random number generator.
set\_seed() allows resetting the value of the random number generated seed to
an earlier value of the seed.
\begin{verbatim}
/LET seed1=get_seed()
/LET number=random(1,1000,1)
The current seed is: /DIS(seed1)
The random number was: /DIS(number)
/LET seed2=get_seed()
/LET number=random(1,1000,1)
The current seed is: /DIS(seed2)
The random number was: /DIS(number)
/LET any_variable=set_seed(seed1)
/LET seed3=get_seed()
/LET number=random(1,1000,1)
The current seed is: /DIS(seed3)
The random number was: /DIS(number)
Output:
The current seed is: 1516840802 1582785437
The random number was: 727
The current seed is: 539910159 1530382995
The random number was: 671
The current seed is: 1516840802 1582785437
The random number was: 727
\end{verbatim}
Note: get\_seed() works like name(), i.e. /DIS(get\_seed()) displays the current seed. On the other hand, set\_seed() behaves like most other functions, i.e. seed=set\_seed(previous\_seed\_variable) which is similar to y=sin(x).
\\ \hline
%*************************************
\index{sub\_string(a,b,c)}{\tt sub\_string(a,b,c)}
& Allows instructor to retrieve part of a previously defined string (a=initial
string, b=place of starting character, c=length of substring).
\begin{verbatim}
/LET string1="Have a nice day."
/LET string2=sub_string(string1,8,4)
/DIS(string2)
Output: nice \end{verbatim}
\\ \hline
\end{tabular}\end{center}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{\small
\begin{center}\begin{tabular}{|p{3.1cm}|p{14.0cm}|} \hline
{ Functions}& Description, sample quizzer code and output \\ \hline
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%*************************************
\index{array[xx]}{\tt array[xx]}
& "xx" can be a variable or a calculation. For example, for the array with name "NaMe":
\begin{verbatim}
/LET index=1
/WHILE ( index<10 )
/LET NaMe[index]=index*10.5
/LET index=index+1
/ENDWHILE
The value of NaMe[7] is /DIS(NaMe[7]:1f)
Output: The value of NaMe[7] is 73.5 \end{verbatim}
\\ \hline
%**************************************
%*************************************
\index{array\_max(Name)}{\tt array\_max(Name)},
\index{array\_min(Name)}{\tt array\_min(Name)}
& For example, for the array NaMe[xx] defined above:
\begin{verbatim}
maximum value of array element = /DIS(array_max(NaMe))
minimum value of array element = /DIS(array_min(NaMe))
Output: maximum value of array element = 94.5
minimum value of array element = 10.5 \end{verbatim}
\\ \hline
%*************************************
\index{array\_moments(B,A)}{\tt array\_moments(B,A)}
& The moments of array A[] are put into array B[i] with i=0 to 4.
B[0]=number of elements, B[1]=mean, B[2]=variance, B[3]= skewness, and B[4]=kurtosis. Note (standard deviation =square root of variance. Example (using NaMe[] array above]
\begin{verbatim}
/LET elements=array_moments(MMT,NaMe)
Displaying the moments:
number of elements=/DIS(MMT[0]:2f)
mean=/DIS(MMT[1]:2f)
variance=/DIS(MMT[2]:2f)
skewness=/DIS(MMT[3]:2f)
kurtosis=/DIS(MMT[4]:2f)
Output: Displaying the moments:
number of elements=9
mean=52.50
variance=826.87
skewness=0.00
kurtosis=-1.60 \end{verbatim}
\\ \hline
%*************************************
\index{init\_array(Name)}{\tt init\_array(Name)}
& Important to initialize when the same array name is used in more than 1 problem in a set. For example, for the array NaMe[xx] above:
\begin{verbatim}
Current value of NaMe[5] = /DIS(NaMe[5]:1f)
/LET deletd=init_array(NaMe)
New value of NaMe[5] = /DIS(NaMe[5]:1f)
Number of array elements deleted = /DIS(deletd)
Output: Current value of NaMe[5] = 52.5
New value of NaMe[5] = VAR "NaMe[5]" NOT DEFINED!
Number of array elements deleted = 9 \end{verbatim}
\\ \hline
%*************************************
\end{tabular}\end{center}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{\small
\begin{center}\begin{tabular}{|p{4.9cm}|p{12.2cm}|} \hline
{ Functions}& Description, sample quizzer code and output \\ \hline
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\index{random\_normal()}
\index{random\_beta()}
\index{random\_gamma()}
\index{random\_exponential()}
\index{random\_poisson()}
\index{random\_chi()}
\index{random\_noncentral\_chi()}
\tt{random\_normal(,,,,)}
\tt{random\_beta(,,,,)}
\tt{random\_gamma(,,,,)}
\tt{random\_exponential(,,,)}
\tt{random\_poisson(,,,)}
\tt{random\_chi(,,,)}
\tt{random\_noncentral\_chi(,,,,)}
&
\tt{random\_normal(return\_array,item\_cnt,seed,av,std\_dev)} \newline
\tt{random\_beta(return\_array,item\_cnt,seed,aa,bb)} \newline
\tt{random\_gamma(return\_array,item\_cnt,seed,a,r)} \newline
\tt{random\_exponential(return\_array,item\_cnt,seed,av)} \newline
\tt{random\_poisson(return\_array,item\_cnt,seed,mu)} \newline
\tt{random\_chi(return\_array,item\_cnt,seed,df)} \newline
\tt{random\_noncentral\_chi(return\_array,item\_cnt,seed,df,xnonc)} \newline
Generate item\_cnt of random numbers according to the particular distribution
with the specified parameters and seed and store them in the array named return\_array.
\\ \hline
Sample Code&Sample Code for \tt{random\_poisson(,,,)} and \tt{random\_normal(,,,,)} is shown on the next page.
\\ \hline
%*************************************
\end{tabular}\end{center}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{\small
\begin{center}\begin{tabular}{|p{3.3cm}|p{13.8cm}|} \hline
%{ Functions}& Description, sample quizzer code and output \\ \hline
%*************************************
\index{random\_poisson(,,,)}{\tt random\_poisson(,,,)}
& FORM: random\_poisson(return\_array,item\_cnt,seed,av) \\
& Array name and 3 parameters needed. Below, the return\_array is called ``RET":
\begin{verbatim}/LET dleted=init_array(RET) // initialize array "RET"
/LET myseed=777 // could be = random(1,10000)
/LET count=10
/LET average=2.2
/LET samples=random_poisson(RET,count,myseed,average)
samples=/DIS(samples); Note `samples' it is the same as `count'
/LET j=0
/WHILE (j <10)
RET[/DIS(j)] = /DIS(RET[j])
/LET j=j+1
/ENDWHILE
OUTPUT: samples=15; Note `samples' it is the same as `count'
RET[0] = 3 RET[1] = 0
RET[2] = 3 RET[3] = 1
RET[4] = 2 RET[5] = 4
RET[6] = 2 RET[7] = 2
RET[8] = 1 RET[9] = 2
\end{verbatim}
\\ \hline
%**************************************
%*************************************
\index{random\_normal(,,,,)}{\tt random\_normal(,,,,)}
& FORM: random\_normal(return\_array,item\_cnt,seed,av,std\_dev) \\
& Array name and 4 parameters needed. (return\_array called ``RET")
\begin{verbatim}/LET dleted=init_array(RET) // initialize array "RET"
/LET myseed=555 // could be = random(1,10000)
/LET count=10
/LET average=6.2
/LET stddev=2
/LET samples=random_normal(RET,count,myseed,average,stddev)
samples=/DIS(samples); Note `samples' it is the same as `count'
/LET j=0
/WHILE (j <10)
/LET RETB[j] = roundto(RET[j],2) // This array is rounded to 2 places
RET[/DIS(j)] = /DIS(RET[j]:4f) and RETB[/DIS(j)] = /DIS(RETB[j]:2f)
/LET j=j+1
/ENDWHILE
OUTPUT: samples=15; Note `samples' it is the same as `count'
RET[0] = 2.9195 and RETB[0] = 2.92
RET[1] = 6.4934 and RETB[1] = 6.49
RET[2] = 7.2427 and RETB[2] = 7.24
RET[3] = 7.0054 and RETB[3] = 7.01
RET[4] = 7.1111 and RETB[4] = 7.11
RET[5] = 8.8491 and RETB[5] = 8.85
RET[6] = 6.9555 and RETB[6] = 6.96
RET[7] = 9.7349 and RETB[7] = 9.73
RET[8] = 8.1034 and RETB[8] = 8.10
RET[9] = 6.8346 and RETB[9] = 6.83 \end{verbatim}
\\ \hline
%**************************************
%*************************************
\end{tabular}\end{center}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\clearpage
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>