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 (23 years, 11 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_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

    1: \hrule 
    2: \vskip 0.2in
    3: \section{\capa{} Functions}
    4: 
    5: \vskip 0.2in
    6: \hrule 
    7: \vskip 0.2in
    8: %>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    9: All of the examples and descriptions used below are for 
   10: student submissions of answers through a Web or telnet session.
   11: There are some changes and additions to the {\sl set$x$.qz} code when using 
   12: \capa\ for machine scored exams.  Please see the next section for those
   13: examples.
   14: 
   15: \subsection{\bf Question source text}
   16: \capa\ assumes that any characters in the
   17: {\sl set$x$.qz} without a special command at the beginning of a line  will be
   18: displayed as text for the student. The following are those special commands: \\
   19: {\tt /LET, \ /BEG, \ /DIS, \ /IMP, \ //, \ /HIN, \ /EXP, \ /MAP, \ /RMAP, \ 
   20: /IF, \ /ELSE, \ /ENDIF, \ /WHILE, \ /ENDWHILE, \ /ANS, \ /AND, \ /OR, \ /SUBJECTIVE, \ /VERB, \ /ENDVERB, \ /START,} and \ {\tt /END}.\\
   21: Text (excluding white space) preceding the forward slash will disable the all
   22: of the commands except {\tt //} and {\tt /DIS}.  Variables must be defined
   23: before use.
   24:  
   25: \subsection{\bf Variable Definitions and Expressions ({\tt /LET}\index{/LET} and  
   26: {\tt /BEG}\index{/BEG} )}
   27: 
   28: \begin{itemize}
   29: \item  Definitions are specified in the form: \\
   30: \fbox{\tt /LET VariableName=expression} 
   31: \item  Variable definitions and expressions begin on a single line with a {\tt /LET} command that is terminated by a carriage return.  
   32: Long entries will be line-wrapped by the editor and may appear to extend past one
   33: line on the display. The line continuation symbol (\verb"\" followed by a carriage return)
   34: can be used to break a long line into several lines and still be considered as
   35: a single long line. 
   36: \item {\tt /BEG} is simply an alias for {\tt /LET}, and is used to indicate the beginning of each problem in the
   37: following manner: \\
   38: \fbox{{\tt /BEG prob\_val=3}}. \\
   39: This sets the variable prob\_val which can 
   40: then be used to define the weight of the problem in the {\tt /ANS} specification the signals the end of the
   41: problem.
   42: 
   43: \item  The \capa\ system does reserve variable names for certain
   44:  functions used in the system. They are listed in the {\bf Intrinsic Functions
   45:  Table}, and must not be used  as variable names.  
   46: \normalsize
   47: 		
   48: \item {\bf List of Available Expressions}:
   49: \begin{tabbing}
   50: 1234567890123456789012345\= 12345678901234567890 \=   \kill
   51: {\it Integer}            \> $\diamond   $ An integer. \\
   52: {\it Real number}        \> $\diamond   $ A real number. It could be of the form
   53: \\{\it $$  } \> $$ 
   54: 123.4, 1.234E+2, 1.234E+2, 1.234E+02, 1.234e+02. \\
   55: {\it ``string''}           \> $\diamond   $ A string. It is specified in the
   56: form \verb+"A block of text"+. \\
   57: %                         \> Quotes may be imbedded in string by prefixing them
   58: % with a `\verb"\\"'. \\
   59: {\it Variable Name}      \> $\diamond   $ A variable previously defined. \\
   60: {\it ( expression )}     \> $\diamond   $ Precedence, evaluate {\it expression}
   61: first. \\
   62: {\it - expression }      \> $\diamond   $ Negative of {\it expression}. \\
   63: {\it function([expression, $\cdots$]) } \> $\diamond   $ Call a function with
   64: arguments. (see below) \\
   65: 
   66: {\it expression $*$ expression } \> $\diamond   $ Multiply expressions. \\
   67: {\it expression $/$ expression } \> $\diamond   $ Divide expresssions. \\
   68: {\it expression $+$ expression } \> $\diamond   $ Add expressions, concatenate
   69: strings \\
   70: {\it expression $-$ expression } \> $\diamond   $ Subtract expressions. \\
   71: {\it expression $==$ expression } \> $\diamond   $ Logical;  expressions equal?
   72: Returns 0 {\small if false}, 1
   73: {\small if true}\\
   74: {\it expression $!=$ expression } \> $\diamond   $ Logical; expressions
   75: different? Returns 0 or 1\\
   76: {\it expression $>=$ expression } \> $\diamond   $ Logical; greater than or
   77: equal? Returns 0 or 1\\
   78: {\it expression $<=$ expression } \> $\diamond   $ Logical; less than or equal?
   79: Returns 0 or 1\\
   80: {\it expression $>$ expression } \> $\diamond   $ Logical; greater than? Returns
   81: 0 or 1\\
   82: {\it expression $<$ expression } \> $\diamond   $ Logical; smaller than? Returns
   83: 0 or 1\\
   84: \end{tabbing}
   85: 
   86: \item  There are three types of variables: integer, real and string. The type
   87: is not explicitly specified but rather is assigned by context at the time the
   88: variable is defined.  
   89: 
   90: \item {\bf Note:}  If you define a variable with an equation consisting
   91: of only integer numbers, then the resulting answer will be an integer.
   92: For example, we have the following code:  \\
   93: \fbox{\tt /LET variable1=1/2} \\
   94: \fbox{\tt /LET variable2=35/12}  \\
   95: Then {\em variable1} will be assigned the value of ``0'' and {\em variable2} will be assigned the value of ``2''.
   96:  On the other hand,   \\
   97: \fbox{\tt /LET variable1=1.0/2.0}  \\
   98: will now be assigned the value of 0.5 because at least one real number was used
   99: in the equation.
  100: 
  101: \item  The variable names must begin with a letter but may contain letters,
  102: numbers, and underline characters.  
  103: 
  104: \item  Variable names (and function names) {\bf are case sensitive}, and
  105: there is no limit on the length of a variable name. 
  106: 
  107: \item  Variables must be defined before they are used in any other expression. 
  108: \normalsize
  109: \item {\bf Note:}  Quotation marks indicate the beginning and end of strings.  You must use a
  110:  backslash to display the quotation marks within a string.  For example: \\
  111:  \fbox{\tt /LET string= ``I'll be back.'' } \\
  112:  will produce
  113:   the ouput ``I'll be back.''
  114:  
  115: \item An expression may be  be broken down into 
  116:        several lines using the line continuation character \verb"\" followed 
  117: \underline{immediately} by a carriage return. This can help improve the legibility 
  118: of the code. Do not use the line continuation character \verb"\" 
  119: within a command, variable, or function name.  
  120:   \begin{capacode}
  121: /LET a_long_line = "This is a very, very, very long statement. It is convenient to \ 
  122: divide it into two lines."
  123:   \end{capacode}
  124: 
  125: \item  Once defined, the same variable can be used at any subsequent point in
  126: the entire problem set or alternatively it could be be redefined.                                           
  127: \end{itemize}
  128: 
  129: 
  130: 
  131: \subsection{\bf Display of Variables \index{/DIS}( {\tt /DIS} )} 
  132: 	\begin{itemize}
  133:   
  134: \item  The {\em value} of a previously defined variable can be displayed in the displayed text
  135: by placing the variable name in the {\tt /DIS()} command,
  136: e.g. {\tt/DIS(}{\em variable}{\tt )}.  
  137: \item The format of the display of a numerical value can be controlled 
  138: using a colon and a format specification.  For example, {\tt /DIS(LENGTH:3f)} means
  139: display the variable {\em LENGTH} as a floating point number with three places
  140: \underline{after} the decimal ({\em x}.{\em xxx}).   {\tt /DIS(LENGTH:2E)} will 
  141: display the variable in scientific notation with two decimal places 
  142: ({\em x}.{\em xx}{\tt E}{\em x}).  The colon is a delimiter indicating that 
  143: a format specification follows.
  144: 
  145: \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, 
  146: accomplished by dragging the lower right corner. 
  147: 
  148: \item  {\tt /DIS(\index{stdline}stdline)} will display a short line that is used to 
  149: seperate problems.  When you build sets 
  150: with {\sf Quizzer} using import, you have the option of displaying a ``standard line'' or a 
  151: {\tt webonlyline} (a line that appears on the web only) after the problem.  When printing two sided,
  152: you have the option of diplaying a {\tt stdlineOvr} which displays the word "Over" so students realize
  153: that the set is two sided.  All of these variables are defined in the {\sl /demolibrary/Tools/StdMacros} file.
  154: 
  155: \item  {\bf Note:} A total of 37 lines are available for telnet display for each question on the VT100 terminal. 
  156: These lines are separated onto two pages
  157: with 20 lines available on the first page and 17 available on the second.  Three lines are repeated for reading
  158: 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
  159: or Web versions of the text. 
  160: 
  161: \end{itemize}
  162: 
  163: %\item  
  164: \subsection{\bf The Import Function ( \index{/IMP}{\tt /IMP} )} 
  165: 
  166: \begin{itemize}
  167: \item  The {\tt /IMP} function calls and uses the contents of the
  168: specified file, however the file's content is not displayed in the {\sl set$x$.qz} 
  169: file.  
  170: \item  The /IMP command requires a string input, either the string
  171: filename or a variable which provides the string filename. 
  172: \begin{enumerate}
  173: \item For example:
  174: \\ \fbox{\tt /IMP "HWTop"} \\
  175:  will import the {\sl HWTop} file from the local directory. 
  176: \item For files in other
  177:  directories, use either relative or absolute paths as part of the filename,
  178:  such as: \\
  179: \fbox{\tt /IMP "/demolibrary/Tools/StdMacros"} \\
  180:  or:  \\
  181: \fbox{\tt /IMP "../mystuff"}. \\
  182: {\bf Note} that if relative paths are used, the {\tt /IMP} command will not work unless it 
  183: is the appropriate directory and can cause errors if the file is moved.
  184: \item The file may be selected 
  185: dynamically
  186:  from a set, for example, 
  187: \begin{capacode}
  188: /LET integer=random(1,10,1)
  189: /LET filename="File"+integer
  190: /IMP filename
  191: \end{capacode}
  192: which will import a randomly selected {\sl File$x$} from {\sl File1, File2, ...File10}. 
  193: \end{enumerate}
  194: {\bf Note:} Adding an integer to a string results in a concatenated
  195: newstring. This can be used to provide even greater variety among
  196: sets for students, since different problems or graphics on a given topic can be selected. 
  197: This feature may be especially useful for producing standardized tests. 
  198: With a large
  199: enough problem base, students can be given a randomly selected set to prepare
  200: for the test. 
  201: \end{itemize}
  202: 
  203: 
  204: \subsection{\bf Comment Lines (\index{//} {\tt //} )} 
  205: 
  206: \begin{itemize}
  207: \item  Comments are any character strings after a double forward 
  208: slash, ({\tt //}).  
  209: For example: 
  210: \begin{capacode} 
  211: //A line of comments
  212: //You can also put comments after code.
  213: /LET number=random(1,4,1) // chooses a random number
  214: \end{capacode}
  215: \item  The comments are only displayed by the {\sf Quizzer} module and are for
  216: the benefit of the persons writing and reviewing the actual problem code.
  217: \item  Instructors are strongly encouraged to include comment lines in order to
  218: indicate authorship and to describe the structure of the problems for future use.
  219: \end{itemize}
  220: 
  221: 
  222: \subsection{\bf Hints (\index{/HIN} {\tt /HIN} )} 
  223: \begin{itemize}
  224: \item Hints are optional. There can only be one hint per problem. 
  225: The hint becomes available after a wrong answer is entered by the student.  
  226: The answer function has reserved syntax for changing the number of entries before displaying the hint.  The notation {\tt /ANS(variable:2f, hint=6)} 
  227: would require that a student enter 6 incorrect answers hefore being presented with the hint.
  228: 
  229: \item  The text for hints contain character strings (no expressions) and can
  230: display string variables defined before the hint to match a problems content,
  231: and is specified as:
  232: 
  233:  
  234: \begin{capacode}
  235: /LET index=random(1,4)
  236: /LET pronoun=choose(index,"he","she","she","he")
  237: /LET ppronoun=choose(index,"his","her","her","his")
  238: /LET person=choose(index,"son","daughter","niece","nephew")
  239: /HIN While her /DIS(person) was being picked up, /DIS(pronoun)
  240: /HIN accidently let /DIS(ppronoun) balloon escape.
  241: \end{capacode}  
  242: 
  243: \normalsize
  244: \item This hint has two lines and two carriage returns. The contents of both
  245: lines are displayed simultaneously; it is not two separate hints.
  246: 
  247: \item  Content of all lines typed  with a {\tt /HIN} at the
  248: beginning are displayed as the hint. The relative ordering of the hint lines is
  249: preserved, and the hint is displayed as a separate page on the
  250: VT100 screen and below the answer box on the web version.  
  251: 
  252: \item Only one {\tt /HIN} is needed if the text is very long and uses the continuation character. 
  253: \begin{capacode}
  254: /HIN A hint is often welcomed by students. It sometimes requires \
  255: a large amount of text  and might require several lines.
  256: \end{capacode} 
  257: Or (no carriage return at all, line wraps automatically):
  258: \begin{capacode}
  259: /HIN A hint is often welcomed by students. It sometimes requires a large amount of text and 
  260: might require several lines.
  261: \end{capacode} 
  262: \item  Hints can also be viewed after a problem set's due date. 
  263: \end{itemize}
  264: \subsection{\bf Explanations (\index{/EXP} {\tt /EXP} )} 
  265: \begin{itemize}
  266: \item   Lines of explanations begin with the {\tt /EXP} characters and are
  267: displayed on the login-terminal only when requested after a problem set is
  268: closed.  The VT100 display offers the option to view a separate page containing
  269: the explanation.  The web version automatically displays the coded explanation
  270: when the student views a closed problem set.
  271: \item The syntax for coding explanations is  very similar to hints. It is 
  272:  useful to include a detailed explanation for some problems. 
  273:  Students often review old problem sets at exam time and may not exactly
  274:  remember how to solve a specific problem.  
  275: \item The following are explanation examples:
  276: \begin{capacode}
  277: /EXP An explanation is often welcomed by students.
  278: /EXP It sometimes requires a large amount of text 
  279: /EXP and might require several lines.
  280: \end{capacode} 
  281: Or:
  282: \begin{capacode}
  283: /EXP An explanation is often welcomed by students. It sometimes requires \
  284: a large amount of text  and might require several lines.
  285: \end{capacode} 
  286: Or (no carriage return at all, line wrap automatic):
  287: \begin{capacode}
  288: /EXP An explanation is often welcomed by students. It sometimes requires a large amount of
  289: text  and might require several lines.
  290: \end{capacode} 
  291: 
  292: \end{itemize}
  293: 
  294: %\item  
  295: \subsection{\bf The Mapping Function ( \index{/MAP}{\tt /MAP} and \index{/RMAP}
  296: {\tt /RMAP} )}
  297: \begin{itemize}
  298: \item  The {\tt /MAP} function is used to map and permute the assigned values 
  299: from a set of variables onto another set of variables according to a given 
  300: seed value. 
  301: \item For example:
  302: 
  303: \begin{capacode}
  304: /LET seed=random(1,3000,1)
  305: /MAP(seed;M1,M2,M3;m,n,o)
  306: \end{capacode}
  307: 
  308: Assigns to the variables $M1$, $M2$, and $M3$ the values of the variables $m$, $n$, and $o$.
  309: The correspondence (i.e. which of $m$, $n$, or $o$ is assigned to $M1$, etc....) is
  310: determined by the value of the variable `seed', which in this example is
  311: selected from 1 to 300.
  312: 
  313: \item The arguments of the {\tt /MAP} function are divided into three portions
  314: by a semicolon symbol (the seed, the variable set, and the defined variable
  315:  set). The value of the seed is used to setup a random number generator 
  316: which is needed to  
  317: select one value from the {\bf second} set of variables and assign it to one of the
  318: variables in the {\tt first} set.  In the above example, two random numbers will 
  319: be generated.
  320: The first random number is then divided by three and the remainder is used to
  321: determine the first value to be selected from the set of three values and 
  322: gets assigned to the first variable in the list. The second random number
  323: is then divided by two and the remainder is used to determine the second
  324: value from the remaining two values and 
  325: is mapped to the second variable.  The very last value left is then 
  326: assigned to the last variable. Therefore, the number of variables in both sets
  327: must be equal. If any of the variables that appear in the  second variable set  
  328: were not previously assigned a value, a warning will be issued.  Variables used in the 
  329: first variable set may contain no data at first, but all variables in the first
  330: variable set will 
  331: receive some value after the {\tt /MAP} function is called. 
  332: 
  333:   
  334: \item The {\tt /MAP} function is used in all the auxiliary files of the multiple
  335: choice templates prepared to facilitate coding of qualitative or conceptual
  336: questions.
  337: 
  338: \item The {\tt /RMAP} function does the reverse action of the {\tt /MAP} function.
  339: The value of the seed is used to setup a random number generator 
  340: which is needed to  
  341: select one variable from the {\bf first} set of variables and map it with one of the
  342: values from the {\tt first} set. 
  343: For example, we have the following code: 
  344: \begin{capacode}
  345: /LET seed=random(1,300,1)
  346: /LET w=1
  347: /LET x=2
  348: /LET y=3
  349: /LET z=4
  350: /MAP(seed;a,b,c,d;w,x,y,z)
  351: /DIS(a), /DIS(b), /DIS(c), /DIS(d)  
  352: 
  353: output:  3, 1, 2, 4
  354: \end{capacode}
  355: The values of the the second set of variables were randomly assigned (dependent
  356: on the seed value) to the first set variables.  
  357: See how the {\bf value} of {\em w} (the first of the four values in its value set) is 
  358: mapped to the {\bf variable} {\em b} (the second of the variables in its set).
  359: If we used {\tt /RMAP} instead with
  360: the same seed value used above in the code below, the resulting mapping is reversed.
  361: Notice how the {\bf variable} {\em a} (the first of the four variables in its set) has the
  362: {\bf value} of {\em x} (the second of the four values) mapped to it.
  363: \begin{capacode}
  364: /LET w=1 
  365: /LET x=2
  366: /LET y=3
  367: /LET z=4
  368: /RMAP(seed;a,b,c,d;w,x,y,z)
  369: /DIS(a), /DIS(b), /DIS(c), /DIS(d)
  370: 
  371: output:  2, 3, 1, 4
  372: \end{capacode}
  373: 
  374: Therefore, {\tt /RMAP} can also be used to unscramble {\tt /MAP}:
  375: \begin{capacode}
  376: /LET seed=random(1,300,1)
  377: /LET w=1
  378: /LET x=2
  379: /LET y=3
  380: /LET z=4
  381: /MAP(seed;a,b,c,d;w,x,y,z)  //same seed as above - not redefined
  382: /RMAP(seed;p,q,r,s;a,b,c,d)
  383: /DIS(p), /DIS(q), /DIS(r), /DIS(s)  
  384: 
  385: output:  1, 2, 3, 4 
  386: \end{capacode}
  387: 
  388: \item To view an example of both the {\tt /MAP} and {\tt /RMAP} see the second
  389: problem in {\sl set19.qz} from the {\sl nsc121s9} class directory({\sl /demolibrary/type-other/OR-MAP-RMAP}).
  390: 
  391: \end{itemize}
  392: 
  393: 
  394: \subsection{\bf Conditional Statements ( \index{/IF}{\tt /IF}, \index{/ELSE}{\tt /ELSE},
  395:  and \index{/ENDIF}{\tt /ENDIF} )}
  396: 	\begin{itemize}
  397: \item {\tt /IF},  {\tt /ELSE}, and {\tt /ENDIF} are used to add conditions within the \capa\
  398: coding.
  399: 
  400: \item For example: 
  401: \begin{capacode}
  402: //NOTE: Each /IF needs an /ENDIF
  403: /LET choice=random(1,4,1)
  404: /IF (choice==1)
  405: If the statement within the parentheses is true, this text
  406: will be printed for the student to read.
  407: /ELSE
  408:  /IF (choice==2)
  409: This line will be printed instead.
  410:  /ELSE
  411:   /IF (choice==3)
  412: This line will be printed.
  413:   /ELSE
  414: If all the conditions above are false, then this text
  415: will be printed.
  416:   /ENDIF  //ends the last /IF condition 
  417:  /ENDIF  //ends the second /IF condition
  418: /ENDIF  //ends the first /IF condition
  419: \end{capacode}
  420: 
  421: \item Other commands can be entered in the {\tt /IF} statement.  For example,
  422: you may have the following:
  423: \begin{capacode}
  424: /IF (choice!=1)
  425: /ANS(5)
  426: /ELSE
  427: /ANS(0)
  428: /ENDIF
  429: \end{capacode}
  430: Therefore, if the variable choice happens to {\bf not} equal the interger 1 then the
  431: the answer is 5, otherwise the answer is 0. \\
  432: \end{itemize}
  433: 
  434: \subsection{\bf Loops ( \index{/WHILE}{\tt /WHILE} and \index{/ENDWHILE}{\tt /ENDWHILE} )}
  435: \begin{itemize}
  436: 
  437: \item Below is an example of the {\tt /WHILE} and {\tt /ENDWHILE} commands: 
  438: \begin{capacode}
  439: Written below are the multiples of 5 up to 12:
  440: /LET integer=0
  441: /WHILE (integer <= 12)
  442: /LET answer = 5*integer
  443: /DIS(integer) * 5 = /DIS(answer) /DIS(web("","//",""))
  444: //see the functions table to see how web() works	
  445: /LET integer=integer+1
  446: /ENDWHILE  
  447: 
  448: The output will display: 
  449: 
  450: Written below are the multiples of 5 up to 12:
  451: 0 * 5 = 0	
  452: 1 * 5 = 5	
  453: 2 * 5 = 10	
  454: 3 * 5 = 15	
  455: 4 * 5 = 20	
  456: 5 * 5 = 25	
  457: 6 * 5 = 30	
  458: 7 * 5 = 35	
  459: 8 * 5 = 40	
  460: 9 * 5 = 45	
  461: 10 * 5 = 50	
  462: 11 * 5 = 55	
  463: 12 * 5 = 60
  464: \end{capacode}
  465: 
  466: As long as the condition in the parentheses is true, the code between 
  467: the {\tt /WHILE} and {\tt /ENDWHILE} will be processed. When the condition
  468: (in this case, the value of the variable {\em integer} is less than or equal 
  469: to 12) is false, control passes to the next line below the {\tt /ENDWHILE}.
  470: 
  471: \item Every {\tt /WHILE} was must have a {\tt /ENDWHILE} to mark the end of the {\tt /WHILE} loop.   \\
  472: \end{itemize}
  473: 
  474: 
  475: \subsection{\bf Answers (\index{/ANS()} {\tt /ANS} )}
  476: \begin{itemize}
  477: 	\item Each individual problem must be ended by an expression specifying the
  478: 	answer. This answer expression consists of the keyword {\tt /ANS()} 
  479: 	starting on a new line.
  480: 	\item The
  481: 	answers are indicated specifically by the {\tt /ANS()} command, with the
  482: 	parentheses containing the answer and the attributes of the answer. 
  483: 	The answers to problems can be previously defined variables. 
  484: 	There must be at least a variable, integer, real number, of string defining the answer within
  485: 	the parentheses, ({\tt /ANS(variable), /ANS(5)}, etc.).
  486: \item Several options are available to format the answer. 
  487: The attributes of the {\tt /ANS()} function are {\bf case insensitive}. 
  488: The available options for defining {\tt /ANS()} attributes are: 
  489: 
  490: 
  491: 
  492: %**********************************************
  493: \item {\bf List of Available Expressions:}
  494: \begin{tabbing}
  495: 12345678901234567890123456789\= 12345678901234567890 \=   \kill
  496: {\tt wgt=}		\> $\diamond    $ problem weight \\
  497: {\tt tries=} {\em or} {\tt try=}    \> $\diamond    $ number of allowed tries to input the answer\\
  498: {\tt tol=}		\> $\diamond	$ answer tolerance \\
  499: {\tt calc=fmt/unfmt}	\> $\diamond	$ sets tolerance to be calculated
  500: 					  from the \\
  501: $$ 	  		\> $ 		$ \ formatted or unformatted answer. \\
  502: {\tt sig=}		\> $\diamond	$ fixed number of significant digits.  \\
  503: {\tt sig=}{\em x} {\tt minus} {\em y} {\tt plus} {\em z}
  504: 			\> $\diamond    $ a range of significant digits from \\
  505: $$			\> $		$ \ {\em x} minus {\em y} to {\em x} plus {\em z}  \\
  506: {\tt unit=} {\em or} {\tt units=} \> $\diamond	$ units of answer (dimensions)\\
  507: {\tt hint=}		\> $\diamond	$ number of wrong student entered 
  508: 					  answers \\
  509: $$ 	  		\> $		$ \ before the hint appears. \\
  510: {\tt str=mc/cs/ci/fml}	\> $\diamond	$ different ways of accepting 
  511: 					  a string answer \\
  512: $$ 	  		\> $		$ \ with fml for math formula as answer. \\
  513: {\tt hgr=on}		\> $\diamond	$ hand graded answer \\
  514: {\tt pc=on}		\> $\diamond	$ partial credit \\
  515: {\tt ansbox=on/off}	\> $\diamond	$ Web generated answer box \\
  516: {\tt br=on/off}		\> $\diamond    $ Web line break \\
  517: \end{tabbing}
  518: \item {\bf More detailed explanations are found below:}
  519: %**********************************************
  520: \begin{enumerate}
  521: %BEGIN DISCRIPTION OF ANSWER OPTIONS
  522: %***********************************************PROBLEM WEIGHT		
  523: 		\item {\bf Problem Weight:\index{WGT=}}  The problem point value (or weight)
  524: 		is set by: \\
  525: 		\fbox{\tt /ANS(variable, wgt=2)}\\
  526: 		  The problem value can
  527: 		be an integer value between 0 and 9.  A variable can be can be 
  528: 		defined at
  529: 		the beginning of a problem by either of the following commands:
  530: \\  \fbox{\tt /BEG prob\_val=3}  \\ 
  531: or \\
  532: \fbox{\tt /LET prob\_val=3} \\
  533: 		Then, this 
  534: 		value can be used in the {\tt /ANS()} function:\\
  535: 		 \fbox{\tt /ANS(variable, wgt=prob\_val, tries=20)}. \\
  536: 		If the problem weight is not defined, the default value
  537: 		of 1 point is used.
  538: %******************************************TRIES
  539: 		\item {\bf Tries:\index{TRY=}\index{TRIES=}}  The number of attempts to enter an incorrect
  540: 		answer can be limited to an integer value less than 
  541: 		or equal to 99.  
  542: \begin{itemize}
  543: \item		The format for setting the number of tries is: \\
  544: 		 \fbox{\tt /ANS(variable, tries=35)} \\
  545: 		or \\
  546: 		\fbox{\tt /ANS(variable, tries=try\_val)} 
  547: \item In the second example shown above, {\em try\_val} is assumed to be a previously defined 
  548: 		variable.
  549: 		The student
  550: 		receives a message near the answer field stating the number of
  551: 		attempts and the total number of tries available for each
  552: 		problem in which the {\tt tries=$x$} has been specified. 
  553: 		A warning message is displayed when only one try
  554: 		remains.
  555: 		Errors in either 
  556: 		significant figures or units will {\bf not} decrease the
  557: 		number of remaining tries for the student. Both the 
  558: 		significant figure 
  559: 		and unit must be correct before 
  560: 		a ``Correct'' or ``Incorrect'' 
  561: 		response to the numerical portion of the answer is given to 
  562: 		the student.   
  563: 		\item {\bf Note:} {\tt try=} is equivalent to {\tt tries=}		\end{itemize}
  564: %*********************************************TOLERANCE
  565: 		\item {\bf Tolerance: \index{TOL=}}  
  566:  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. 
  567: \begin{enumerate}
  568: 		\item The format for a set numerical value would be given by:\\
  569: 		\fbox{\tt /ANS(variable:3f,tol=0.5)} 
  570: 		\item The format of a \% tolerance would be given by: \\
  571: 		\fbox{\tt /ANS(variable:3f, tol=1.1\%)}. \\ 
  572: 		This is specified if there is a possibility that the 
  573: 		answer will be calculated as equal to zero.  The tolerance 
  574: 		is thus given a value rather than a percentage.
  575: 		\item The format for a defined tolerance variable would be: \\
  576: 		\fbox{\tt /ANS(variable:3f, tol=TolVar)}. \\
  577: 		\item The format for a \% tolerance with a defined variable would be: \\
  578: 		\fbox{\tt /ANS(variable:3f, tol=TolVar\%}
  579: 		\end{enumerate}
  580: 	{\em Note that the display of the answer can be formatted according to the same commands used
  581: 	in /DIS.}
  582: \begin{itemize}
  583: 	\item {\bf Real answers:} A tolerance should be specified 
  584: 	for `real' answers. It can be
  585: 	absolute or relative.  An absolute tolerance can be a variable.
  586: Answers with real values can be {\bf formatted} with
  587:  specifications {\tt :1E, :3E, 
  588:  :2f,}
  589:  etc., where {\tt 1E} means exponential notation with one decimal place, 
  590:  {\tt :3E} means exponential notation with three
  591:  decimal places, and {\tt :2f} means two floating decimals.
  592: 		\begin{enumerate}
  593: 		\item \fbox{\tt /ANS(variable:2E,tol=1.2\%,wgt=prob\_val,tries=try\_val)} 
  594: 		\\ When
  595: 		an answer submitted by a student is within the relative
  596: 		tolerance (1.2\% ) of the correct answer, the student receives 
  597: 		`correct'.  {\bf Note:} The relative tolerances are  based
  598: 		on the {\bf unformatted} answer.
  599: 		\item \fbox{\tt /ANS(variable:2E,tol=5.0,wgt=prob\_val,tries=try\_val)}
  600: 		\\  An answer
  601: 		submitted by a student within the absolute tolerance of 5.0,
  602: 		would be graded `correct'.  That is the answer must lie within the range {\em variable}-5
  603: 		to {\em variable}+5. 
  604: 
  605: 		\item \fbox{\tt /ANS(variable:3E,tol=tol\_val,wgt=prob\_val, tries=try\_val)}   \\
  606: 		 Here the tolerance is a previously defined quantity,
  607: 		{\tt tol\_val}. 
  608: 		\item {\tt calc=fmt/unfmt}:  Selects the application of the 
  609: 		tolerance range for the formatted or unformatted numerical
  610: 		answer value.  For example, say we have {\tt variable=2/3} for the following answer line: \\
  611: 		\fbox{\tt /ANS(variable:3f,tol=.01,wgt=prob\_val, tries=try\_val)} \\
  612: 		the error would be between two-thirds plus or minus .01.  If we used this instead though: \\
  613: 		\fbox{\tt /ANS(variable:3f,tol=.01,calc=fmt,wgt=prob\_val,tries=try\_val)} \\
  614:                 the error would be between 0.667 plus or minus 0.01.  The default value is unformatted.
  615: 		\end{enumerate}
  616: 	\item {\bf Integer answers:}  You may not want a tolerance for an 
  617: integer answer.  \\
  618: \fbox{\tt /LET variable=34}
  619: 		\begin{enumerate}
  620: 		\item \fbox{\tt /ANS(variable, tol=0, wgt=prob\_val,tries=try\_val, hint=hint\_val)}\\
  621: 		 Only the number ``34'' will be
  622: 		accepted as correct. 
  623: 	\item \fbox{\tt /ANS(variable, wgt=prob\_val, tries=try\_val, hint=hint\_val)}\\
  624: 		Same as above.  Only the number ``34'' will be accepted as 
  625: 		correct.
  626: 		\item You can also use a percentage tolerance or a non-integer real
  627: 	number as a tolerance, but then students can get a ``correct'' answer
  628: 	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)} 
  629: \\		Any answer within plus or
  630: 		minus 4 units is accepted as  correct.  For example, the 
  631: 		real number, 36.5 will be accepted as ``correct''.
  632: 		\end{enumerate}
  633: 
  634: 	\item {\bf Note:} If you define your answer variable with an equation consisting
  635: of only integer numbers, then the resulting answer will be an integer.
  636: For example, we have the following code: \\
  637: \fbox{\tt /LET variable1=1/2} \\
  638: \fbox{\tt /LET variable2=35/12}  \\
  639: Then {\em variable1} will be assigned the value of ``0'' and {\em variable2} will be assigned the value of ``2''.  On the other hand,   \\
  640: \fbox{\tt /LET variable1=1.0/2.0}  \\
  641: will now be assigned the value of 0.5 because at least one real number was used
  642: in the equation.
  643: \footnote{You may have noticed this text from the /LET section, but it is worth repeating because it can be
  644: a major source of frustration to the instructor and students if real numbers and integer numbers are not
  645: dealt with correctly.}
  646: \end{itemize}
  647: %************************************************SIGNIFICANT FIGURES	
  648: 		\item {\bf Significant Figures:\index{SIG=}}  
  649: 		If unspecified, significant figures are  not checked and 
  650: 		any number of significant figures between 1 and 15 are 
  651: 		accepted provided the answer entered falls within the	
  652: 		specified numerical tolerance range. The number of acceptable
  653: 		significant figures can be specified by the following format: 
  654: \begin{enumerate}
  655: \item \fbox{\tt /ANS(variable, sig=4 plus 1 minus 1, tries=try\_val, wgt=prob\_val, hint=hint\_val)} \\ 
  656: 		This will accept 3, 4, or 5 significant figures in the answer. 
  657: \item		\fbox{\tt /ANS(variable, sig=3 plus 2, tries=try\_val, wgt=prob\_val, hint=hint\_val)}  \\ 
  658: 	       This will accept 3, 4, or 5 significant figures in the answer. 
  659: \item	 \fbox{\tt /ANS(variable, sig=4 , tries=try\_val, wgt=prob\_val, hint=hint\_val)} \\
  660: 		This will only accept  4 significant figures in the answer. 
  661: \end{enumerate}
  662: 		Care must be exercised when limiting the significant figures
  663: 		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: \\
  664: \fbox{\tt /ANS(variable:0f, sig=1, tol=1\%, wgt=prob\_val)} \\
  665: The student will calculate this answer to be 4E-1 which is not within 1\% of the
  666: answer.
  667: 		
  668: %********************************************UNITS		
  669: 		\item {\bf Units:\index{unit=}}  A file in the class
  670: 		directory named {\sl capa.config} lists all SI units and other
  671: 		user defined acceptable units with 
  672: 		their relationships.
  673: 		That file can be edited by the instructor. 
  674: 		Units are entered as strings.  
  675: \begin{itemize}
  676: \item A typical format for 
  677: 		answers requiring a unit is: \\ 
  678: 		\fbox{\tt /ANS(perimeter:3f,unit="cm",sig=4)}\\
  679: 		or\\ 
  680: 		\fbox{\tt /ANS(area:2f,unit="cm\^{}2")} 
  681: \item For a specially defined unit, one can use a variable, e.g. 
  682: \begin{capacode} /LET StringVar="dollar"
  683: /ANS(cost:2f,unit=StringVar,tol=.005,wgt=2,tries=6,sig=4 plus 3)
  684: \end{capacode}
  685: 		\item {\sl /demolibrary/type03/msu-prob22.txt} and
  686: 		{\sl /demolibrary/type03/msu-prob23.txt} \\ are two problems 
  687: 		included in the distribution
  688: 		package which aid in teaching students the rules for entering 
  689: answers with units in a \capa\ session. These are useful for students in an initial \capa\ set.  
  690: 		\item {\bf Note:} {\tt units=} is equivalent to {\tt unit=}
  691: \end{itemize}
  692: %************************************************SHOW HINTS	
  693: 		\item {\bf Show Hints:\index{hint=}}  The hint can be configured so that it 
  694:    		is available or displayed only after a certain number of tries.
  695:       		 This is achieved by setting {\tt hint=AnInteger} (e.g. {\tt hint=3}) 
  696: 		in the answer format. 
  697: 		 For example: \\
  698: 		\fbox{\tt /ANS(variable, hint=3, tries=10, wgt=1)} \\
  699: 		or  \\
  700: 		\fbox{\tt /ANS(variable, hint=hint\_val, tries=10, wgt=1)}\\
  701: 		will both
  702: 		(1) show the hint on a Web browser after 3 tries
  703: 		and (2) allow it to be viewed on telnet after 3 or more tries
  704: 		 by entering :H which shows up on the menu lines. 
  705: %***********************************************STRING ANSWERS	 
  706: 
  707: 
  708: 	\item {\bf String answers} can be exact comparisons, or have the order
  709: 	and/or case disregarded.
  710: 		\begin{enumerate}
  711: 		\item \fbox{\tt /ANS(letters,str=ci,wgt=prob\_val,tries=20)} \\
  712: 		{The command {\tt str=ci} is the default value, the order is checked but case insensitive.}		
  713: 		\item \fbox{\tt /ANS("KCl",wgt=prob\_val,tries=20)}\\
  714:  { The default is case insensitive.  Therefore, answers such as ``kcl'' and 
  715: 		``KcL'' are accepted as correct.} 
  716: 		\item \fbox{\tt /ANS(letters,wgt=prob\_val,tries=20)}\\
  717: { 		{\em letters} is a string variable previously defined. This works
  718: 		like the example above.  (The order is essential, but
  719: 		not case sensitive.)}
  720: 		\item \fbox{\tt /ANS(letters,str=mc,wgt=prob\_val,tries=20)}\\
  721:   		{The command
  722: 		{\tt str=mc} accepts any order of the correct responses.  
  723: 		Hence, ``abc'' and ``acb'' are equivalent.}
  724: 		\item \fbox{\tt /ANS(letters,str=cs,wgt=prob\_val,tries=20)} \\ 
  725: 		{This is an exact string comparison. Both the order and
  726: 		the case are required.}
  727: 		\item {\bf Formula as string answer:}
  728:                 \begin{capacode} 
  729:                 /ANS(fm1,str=fml,eval=<"x" @ pt1:pt2#20>,TOL=1E-3, tries=try_val, 
  730: wgt=prob_val,hint=hint_val)    \end{capacode}
  731: 		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.\\
  732: {\em For examples, see the templates: \\{\tt /demolibrary/MCTools/equationA} and {\tt /demolibrary/MCTools/equationXY} }
  733: 		\end{enumerate}
  734: %********************************************HAND GRADING		
  735: 		\item {\bf Hand Grading:\index{hgr=}}  A problem can be designated to be hand
  736: 		graded.  For this case students are not allowed to answer
  737: 		via telnet or web sessions and the question is graded by the instructor using the {\sf Grader} application.  
  738: 		  The format for this is: \\
  739: 		{\tt /ANS(variable,hgr=on, tries=1, wgt=1)} \\
  740: 		{\em (See /SUBJECTIVE for telnet or
  741: 		Web submitted essay questions for hand grading.)}
  742: %*******************************************PARTIAL CREDIT		
  743: 		\item {\bf Partial Credit:\index{pcr=}}  A multiple point problem can be
  744: 		specified to have partial credit.  This attribute works like
  745: 		{\tt hgr=on} in that students cannot login to
  746: 		answer the question.  The format for this is: \\
  747: 		\fbox{\tt /ANS(variable, wgt=9, pcr=on, tries=1)}\\
  748: 		  This allows an instructor to
  749: 		manually enter an integer point value from 0 to 9 through the 
  750: 		{\sf Grader} application.
  751: 
  752: 
  753: %**********************************************MISCELLANEOUS ANSWER ATTRIBUTES
  754: 
  755: 	\item {\bf Miscellaneous Answer Attributes}
  756: 		\begin{enumerate}
  757: 		\item {\tt br=on/off}:  This starts/stops the generation of 
  758: 		$<$br$>$ (a line break) on the Web display.  The default value is on.
  759: 		\item {\tt ansbox=on/off}:  Controls the generation and display 
  760: 		of the answer box for the Web.  The default value is on.  
  761: 		\item {\tt Yes/no} is equivalent to {\tt on/off}.
  762: 		\end{enumerate}
  763: %*******************************************END OF ANSWER ATTRIBUTES
  764: \end{enumerate}
  765: \end{itemize}
  766: 
  767: \subsection{\bf Multiple Answers ( \index{/AND}\index{/OR}{\tt /AND} and {\tt /OR} )} 
  768: \begin{itemize}
  769: \item  {\tt /AND} or {\tt /OR} after an answer specification requires another {\tt /ANS} statement be present. 
  770: In the case of {\tt /AND}, two successive answers will be required from the student.  In the case of {\tt /OR},
  771: the student will receive credit if either answer is supplied.
  772: \item Below is an example for {\tt /AND}: 
  773: \begin{capacode}
  774: /ANS(variable_1, wgt=prob_val, tries=try_value)
  775: /AND
  776: /ANS(variable_2, wgt=prob_val, tries=try_value)
  777: \end{capacode}
  778: 
  779: The above example requires two answers from the student.
  780: During a telnet session the student will be prompted to enter the first 
  781: answer and then the second {\bf in the order that they are coded}.  
  782: During a web session, there will be multiple answer boxes labeled ``Answer 1''
  783: and so on.  Again, they must be entered in order by the student.  It is 
  784: recommended that the problem text give instructions to the student to answer the questions in order.
  785: Note that the problem is worth the number of points of the last defined {\tt wgt} specification, i.e. if in the
  786: first answer {\tt wgt=3} and in the second answer {\tt wgt=1}, the student will only receive one point for
  787: the total question.
  788: \item Below is an example for {\tt /OR}: 
  789: \begin{capacode}
  790: /ANS(variable_1, wgt=prob_val, tries=try_value)
  791: /OR
  792: /ANS(variable_2, wgt=prob_val, tries=try_value)
  793: \end{capacode}
  794: 
  795: The {\tt /OR} is suitable for questions such as asking the student to choose one 
  796: of the correct answers from a list.
  797: \item Note that the variable {\em try\_val} was used in the examples above
  798: to simplify the script. If the number of tries is different within the answer
  799: specifications, the last defined
  800: number of tries is given to the student for their amount of tries in that
  801: problem.
  802: \end{itemize}
  803: 
  804: 
  805: \subsection{\bf Essay Questions (\index{/SUBJECTIVE} {\tt /SUBJECTIVE} )} 
  806: {\tt /SUBJECTIVE} is used instead of {\tt /ANS} when the instructor wants to allow students
  807: to submit a short essay.   
  808: The student can type their essay in either
  809: the telnet or web session.  The instructor grades this essay with the
  810: {\sf Grader} application and the score is recorded in the database.
  811: {\tt hgr=on} must be specified when using {\tt /SUBJECTIVE}.  
  812: \begin{capacode} /SUBJECTIVE(wgt=prob_val, hgr=on, tries=try_val) 
  813: \end{capacode}
  814: You may choose to set a number of tries also.  The student will be allowed to rewrite their essay according
  815: to the number of tries that the instructor allows.
  816: 
  817: \subsection{\bf Displaying text verbatim (\index{/VERB} \index{/ENDVERB} {\tt /VERB} and {\tt /ENDVERB} )} 
  818: Used to display text verbatim:
  819: \begin{capacode}
  820: Enter the answer as in a calculator: 
  821: /VERB 
  822: Example: 4.567 + 2.431 * x^4 - 0.310 * x^2 
  823: /ENDVERB
  824: \end{capacode}
  825: 
  826: 
  827: 
  828: \subsection{\bf Displaying Information Before the Problem Set (\index{/START} {\tt /START} )} 
  829: All the material coded before {\tt /START} in a {\sl set$x$.qz} file is both printed
  830: out and displayed on the Web for students to see.  See {\sl set19.qz} in the 
  831: {\sl nsc121s9} class directory for an example (note the placement of the imported {\sl HWTop} file).
  832: 
  833: \subsection{\bf Ending the Problem Set ( \index{/END}{\tt /END} )} 
  834: \begin{itemize}
  835: \item {\tt /END()} or {\tt /END(\index{stdendline}stdendline)} causes the parser to stop and ignore all input
  836: characters beyond that command.  String variables can be defined and constructed and additional text
  837: (such as instructions for students) may be displayed between the last {\tt /ANS()} and 
  838: {\tt /END}. 
  839: 
  840: \item All sets should include {\tt /END(stdendline)}, so that both on 
  841: paper and on the Web,  the department is identified and the 
  842: copyright nature of the \capa\ software is indicated. The string for 
  843: {\tt stdendline} is created in the {\sl HWTop} file in the class directory and can be
  844: edited by users, such as changing the Dept. ID for your particular class.
  845: 
  846: \item The \capa\ system counts the number of problems in a problem set by
  847: counting the number of {\bf proper} answer lines (lines containing {\tt /ANS} or {\tt /SUBJECTIVE}).  If there is
  848:  an error in coding and the answer cannot be evaluated, that problem is not
  849:  counted by {\sf Quizzer}.
  850: \end{itemize}
  851: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  852: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  853: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  854: {\small 
  855: \begin{center}\begin{tabular}{|p{2.9cm}|p{14.2cm}|}    \hline
  856: \multicolumn{2}{|c|}{\bf Table of Intrinsic Functions: Names Are Case
  857: Sensitive.}\\ \hline
  858: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  859: { Functions}& Description, Sample quizzer input  and output for  printing \\ \hline
  860: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  861: \index{sin()}\index{cos()}\index{tan()}{\tt sin(x), cos(x), tan(x)}&   Trigonometric functions. x is in radians.  
  862: \begin{verbatim}/LET angle=60.0
  863: /LET var1=sin(angle*3.141592654/180)
  864: Sine of /DIS(angle:1f) degrees is /DIS(var1:3f). 
  865: \end{verbatim}  
  866: Output: {\tt  Sine of 60.0 degrees is 0.866. }\\ \hline
  867: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  868: \index{asin()}\index{acos()}\index{atan()}\index{atan2()}{\tt asin(x), acos(x), atan(x), atan2(y,x)}& Inverse trigonometric functions. Returns
  869: radians. asin() computes the principal value of the arc sine of x, in the
  870:   interval [-pi/2,pi/2] radians. The value of x must be in the domain [-1,1].
  871:   acos() computes the principal value of the arc cosine of x, in
  872:   the interval [0,pi] radians. The value of x must be in the domain [-1,1].
  873:   atan2() computes the principal value of the arc tangent of y/x,
  874:   in the interval [-pi,pi] radians.  The sign of atan2() is
  875:   determined by the sign of y.
  876: \begin{verbatim}/IMP "demolibrary/Tools/StdConst"
  877: //pi_c is a variable set to equal pi and is found in  the imported file above.
  878: /LET var1=-1.65
  879: /LET var2r=atan(var1)
  880: /LET var3d=atan(var1)*180.0/PI
  881: The angle whose tangent is /DIS(var1:3f) can be expressed
  882: as /DIS(var2r:3E) radians or as /DIS(var3d:3E) degrees. 
  883: \end{verbatim}
  884: Output for telnet session:
  885: {\tt The angle whose tangent is -1.650 can be expressed
  886: as -1.026E+00 radians or as -5.878E+01 degrees.}
  887: \\ \hline
  888: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  889: \index{log()}\index{log10()}{\tt log(x), log10(x)}& Natural logarithm and base-10 logarithm. Note that the
  890: the variables {\tt natlog} and {\tt tenlog}  were defined to simplify the coding
  891: of this problem by allowing complicated text (with subscripts and superscripts)
  892: to be printed by displaying a variable.
  893: \begin{verbatim}
  894: /LET natlog=tex("$log_e$","log_e")
  895: /LET tenlog=tex("$log_{10}$","log_10")
  896: /LET x=2546.7
  897: /LET var1=log(x)
  898: /LET var2=log10(x)
  899: /LET ratio=var1/var2
  900: /LET var3=log(10.0)
  901: The /DIS(natlog) of /DIS(x:1f) is /DIS(var1:3E) while its /DIS(tenlog)
  902: is /DIS(var2:3E). Note that the ratio /DIS(natlog)//DIS(tenlog)
  903: = /DIS(ratio:3f), which is just /DIS(natlog)(10), i.e. /DIS(var3:3E).
  904: \end{verbatim}
  905: Output for print out or Web:  
  906: The $log_e$ of 2546.7 is $7.843$ while its
  907: $log_{10}$
  908: is $3.406$. Note that the ratio $log_e$/$log_{10}$
  909: = 2.303, which is just $log_e$(10), i.e. $2.303$.
  910: \\ \hline
  911: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  912: \index{exp()}\index{pow()}\index{sqrt()}{\tt exp(x), pow(x,y), sqrt(x)}& Exponential, power, and square root.
  913: Compute $e^x$, $x^y$, and $\sqrt{x}$ respectively. 
  914: \begin{verbatim}/LET varx=1.526
  915: /LET vary=0.5
  916: /LET var1=exp(varx)
  917: /LET var2=pow(varx,0.5)
  918: /LET var3=pow(varx,vary)
  919: /LET var4=sqrt(varx)
  920: var1=/DIS(var1:2f);  var2=/DIS(var2:2f); var3=/DIS(var3:2f);
  921: var4=/DIS(var4:2f). 
  922: 
  923: \end{verbatim}
  924:  Output: {\tt  var1 = 4.60;  var2 = 1.24; var3 = 1.24;  var4 =
  925: 1.24.} 
  926: \\ \hline
  927: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  928: \end{tabular}\end{center}}
  929: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  930: {\small 
  931: \begin{center}\begin{tabular}{|p{2.9cm}|p{14.2cm}|}    \hline
  932: { Functions}& Description, sample quizzer code and output \\ \hline
  933: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  934: \index{abs()}\index{sgn()}{\tt abs(x), sgn(x)}& {\tt abs(x)} returns the absolute value of $x$.
  935:                       {\tt sgn(x)} returns $1$, $0$ or $-1$ depending on value
  936:                       of $x$ 
  937: \begin{verbatim}/LET xx=-2.5
  938: /LET var1=abs(-4.5)
  939: /LET var2=sgn(xx)
  940: /LET var3=sgn(-4.5*xx)
  941: var1=/DIS(var1:2f)  var2=/DIS(var2)  var2=/DIS(var2:2f) var3=/DIS(var3)
  942: \end{verbatim}
  943:  Output: {\tt  var1=4.50  var2=-1 var2=-1.00 var3=1
  944:  }\\ \hline
  945: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  946: \index{erf()}\index{erfc()}{\tt erf(x), erfc(x)}& Error functions. ${erf}(x) = \frac{2}{\sqrt{\pi}}
  947: \int_0^{x} e^{-t^2} dt$ and
  948: ${erfc}(x) = 1.0 - {erf}(x)$.
  949: \begin{verbatim}/LET varx=0.51
  950: Evaluate the Normal Probability Integral from -/DIS(varx)
  951: to /DIS(varx). /DIS(newline) 
  952: /LET prob = erf(varx/sqrt(2.0))
  953: Probability = /DIS(prob:4f) 
  954: \end{verbatim}
  955:  Output: {\tt  Evaluate the Normal Probability Integral from -0.51
  956: to 0.51. }
  957: \newline {\tt Probability = 0.3899} 
  958:  \\ \hline
  959: %$\mathrm{erfc}(x) = 1.0 - \mathrm{erf}(x)$.}\\ \hline
  960: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  961: \index{ceil()}\index{floor()}{\tt ceil(x), floor(x)}& Ceiling and floor functions.
  962: ${ceil}(x) = \lceil x \rceil$ and ${floor}(x) = \lfloor
  963: %$\mathrm{ceil}(x) = \lceil x \rceil$ and $\mathrm{floor}(x) = \lfloor
  964: x \rfloor$. The ceiling function returns an integer rounding x toward positive
  965: infinity. The floor function rounds toward negative infinity.  
  966: \begin{verbatim}/LET varx=ceil(3.65)
  967: /LET vary=floor(3.65)
  968: /LET varz=ceil(-5.73)
  969: /LET varw=floor(-5.73)
  970: varx=/DIS(varx) vary=/DIS(vary) varz=/DIS(varz) varw=/DIS(varw)
  971: \end{verbatim}
  972:  Output: {\tt  varx=4 vary=3 varz=-5 varw=-6
  973: }\\ \hline
  974: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  975: \index{min()}\index{max()}{\tt min(...), max(...)}& Minimum and maximum functions, with indefinite number
  976: of arguments.
  977: Arguments must be of either all integer or real type.  String comparison are
  978: such that $A < a$.  In other words,
  979: lower case letters have a higher value than upper case letters.
  980: \begin{verbatim}/LET a=min(23,45,12,7,9)
  981: /LET b=max(23.1,45.3,12.6,7.1,9.0)
  982: /LET c=min("a","ae","aeg","Aeg")
  983: /LET d=max("a","ae","aeg","Aeg")
  984: a=/DIS(a:2f) b=/DIS(b:2f) c=/DIS(c) d=/DIS(d) 
  985: \end{verbatim}
  986:  Output: {\tt  a=7 b=45.30 c=Aeg d=aeg 
  987: }\\ \hline
  988: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  989: \end{tabular}\end{center}}
  990: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  991: {\small 
  992: \begin{center}\begin{tabular}{|p{2.9cm}|p{14.2cm}|}    \hline
  993: { Functions}& Description, sample quizzer code and output \\ \hline
  994: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  995: \index{factorial()}{\tt factorial(n)}& Arguments must be an integer. Returns an integer if n is or
  996: smaller, else or real value.  
  997: \begin{verbatim}/LET number=factorial(6)
  998: /DIS("6!=")/DIS(number)/DIS(newline)
  999: /DIS("0!=")/DIS(factorial(0))/DIS(newline)
 1000: /LET number2=factorial(21)
 1001: /DIS("21!=")/DIS(number2:3E)/DIS(newline) \end{verbatim}
 1002:  Output: {\tt 
 1003: 6!=720\newline
 1004: 0!=1\newline
 1005: 21!=$5.109 \times 10^{19}$
 1006: }\\ \hline
 1007: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 1008: \index{modulus operator, \%}
 1009: {\tt N\% M}& N and M are integers, and the remainder of the integer ratio is
 1010: returned.
 1011: \begin{verbatim}
 1012: /LET ratio = 98/5
 1013: /DIS("ratio=")/DIS(ratio)/DIS(newline)
 1014: /LET leftover=98%5
 1015: /DIS("remainder=")/DIS(leftover) \end{verbatim}
 1016: 
 1017:  Output: {\tt 
 1018: ratio=19\newline
 1019: remainder=3 }\\ \hline
 1020: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 1021: \index{hyperbolic functions}
 1022: {\tt sinh(x), cosh(x), tanh(x)} & Hyperbolic functions.\\ \hline
 1023: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 1024: \index{hyperbolic functions, inverse}
 1025: {\tt asinh(x), acosh(x), atanh(x)}& Inverse hyperbolic functions.\\ \hline
 1026: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 1027: \index{roundto()}
 1028: {\tt roundto(var1,n)} & Rounds the value of real variable `var1' to n places (fixed point notation).
 1029: \begin{verbatim}
 1030: /LET value=100.0/3.0
 1031: Initial value = /DIS(value:5f)/DIS(newline)
 1032: /LET value=roundto(value,2)
 1033: The new value is now /DIS(value:5f) and can be used as 
 1034: /DIS(value:2f) with no rounding error. \end{verbatim}
 1035: 
 1036:  Output: {\tt Initial value =
 1037: 33.33333
 1038: The new value is now 33.33000 and can be used as 33.33 with no rounding
 1039: error.}\\ \hline
 1040: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 1041: \index{web()}{\tt web("a","b","c") or web(a,b,c) }& ASCII (a), tex(b) and html(c) strings or
 1042: variables displayed respectively. 
 1043: \begin{verbatim}
 1044: Example: \verb+{/DIS(web("M2","M$_2$","M<sub>2</sub>")) }+ 
 1045: 
 1046: Output for telnet session: M2 
 1047: Output for printout or Web: M$_2$
 1048: \end{verbatim} 
 1049: \\ \hline
 1050: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 1051: \index{html()}{\tt html(a)  or html("a")} & variable or string `a' parsed for Web browser only.  
 1052: \begin{verbatim}
 1053: Example: 
 1054: /DIS(html("<br><a href=/nsc121s9/Links/webPulley.html> Motion of Masses  \ 
 1055: on a Pulley</a><p>")) 
 1056: \end {verbatim}
 1057: Displays link "Motion of Masses on a Pulley"
 1058: \\ \hline
 1059: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 1060: \end{tabular}\end{center} }
 1061: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 1062: {\small 
 1063: \begin{center}\begin{tabular}{|p{2.9cm}|p{14.2cm}|}    \hline
 1064: { Functions}& Description, sample quizzer code and output \\ \hline
 1065: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 1066: {\tt \index{Bessel functions, jn() and yn()}jn(0,x), jn(1,x), jn(n,x)}& Bessel functions of the first kind, with orders
 1067: $0$, $1$ and $n$ respectively. Note that the first argument is  integer, the
 1068: second real.
 1069: \begin{verbatim}/LET aa=jn(0,3.0)
 1070: /LET bb=jn(1,3.0)
 1071: /LET cc=jn(2,3.0)
 1072: aa=/DIS(aa:4f) bb=/DIS(bb:4f) cc=/DIS(cc:4f)
 1073: \end{verbatim}
 1074:  Output: {\tt aa=-0.2601 bb=0.3391 cc=0.4861
 1075: }\\ \hline
 1076: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 1077: {\tt \index{yn()}yn(0,x), yn(1,x), yn(n,x)}& Bessel functions of the second kind, with
 1078: orders $0$, $1$ and $n$ respectively.  Note that the first argument is  integer,
 1079: the second real.
 1080: \begin{verbatim}/LET dd=yn(1,3.0)
 1081: dd=/DIS (dd:4f)
 1082: \end{verbatim}
 1083:  Output: {\tt  dd=0.3247
 1084: }\\ \hline
 1085: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 1086: {\tt \index{random()}random(l,u,d)}& Returns a uniformly distributed random number
 1087: between $l$ and $u$ with steps of  $d$.  Note that all
 1088: arguments must be the same type, integer or real. {\footnotesize [When real number are used, avoid having 
 1089: the step size such that the highest value lands on "u" as different machines may have different representations and accuracy.]}
 1090: \begin{verbatim}/LET index=random(2,5,2) //returns integers 2 or 4
 1091: /LET value=random(2.3,5.15 ,0.2 ) //returns 2.3, 2.5, 2.7,...., 5.1 
 1092: index=/DIS(index) value=/DIS(value:2f)
 1093: \end{verbatim}
 1094:  Output: {\tt  index=4 value=3.70
 1095: }\\ \hline
 1096: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 1097: \index{choose()}
 1098: {\tt choose(i,...)}& Choose the $i$th item in the argument list. Integer $i$
 1099: must be greater than zero and
 1100:  it's maximum possible value must not exceed the number of arguments following
 1101:  it. 
 1102: \begin{verbatim}/LET indx=3
 1103: /LET realvar=choose(indx, 23.0,45.4,67.3) // will select 67.3
 1104: /LET intvar=choose(indx, 23,45,67) // will select 67
 1105: /LET stringvar=choose(indx,"No","Yes","Maybe") // will select "Maybe"
 1106: realvar=/DIS(realvar:2f) intvar=/DIS(intvar) stringvar=/DIS(stringvar) 
 1107: \end{verbatim}
 1108:  Output: {\tt  realvar=67.30 intvar=67 stringvar=Maybe 
 1109:  }\\ \hline
 1110: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 1111: \index{tex()}
 1112: {\tt tex(a,b)}, {\tt tex("a","b")}& When in TeX mode, return the first argument
 1113: $a$, and return the second argument $b$ in enscript mode (ASCII).
 1114: \begin{verbatim}/DIS(tex("This, in the .tex file.","This, in the ASCII version."))
 1115: /LET A=33
 1116: /LET B=66
 1117: /DIS(tex(A,B)) 
 1118: \end{verbatim}
 1119: Tex Output: This, in the .tex file. 33 
 1120: \\ \hline
 1121: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 1122: {\tt var\_in\_tex(a)}& Equivalent to  {\tt tex("a","")}
 1123: \\ \hline
 1124: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 1125: \end{tabular}\end{center}}
 1126: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 1127: {\small 
 1128: \begin{center}\begin{tabular}{|p{2.9cm}|p{14.2cm}|}    \hline
 1129: { Functions}& Description, sample quizzer code and output \\ \hline
 1130: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 1131: \index{to\_string()}{\tt to\_string(x)}, {\tt to\_string(x,y)}& If variable x is an integer,
 1132: to\_string(x) returns a string. If x
 1133: is real the format is given by y as follows: 
 1134: \begin{verbatim}
 1135: /LET name1=to_string(34.56789)
 1136: /LET name2=to_string(34.56789, ".3E")
 1137: /LET name3=to_string(34.56789, ".3f")
 1138: 
 1139: No format is /DIS(name1), with ".3E" format is /DIS(name2), 
 1140: and with ".3f" format is /DIS(name3) 
 1141: \end{verbatim}
 1142: Output:
 1143: No format is 34.56789, with ".3E" format is 3.457E+01, 
 1144: and with ".3f" format is 34.568 
 1145: \\ \hline
 1146: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 1147: \index{capa\_id()}\index{class()}\index{section()}\index{set()}\index{problem()}
 1148: {\tt capa\_id(), class(), section(), set(), problem()}& The \capa\ ID number,
 1149: class name, section number, set number
 1150: and problem number respectively. Variables can be assigned to their current values
 1151: or they can be displayed directly as shown below.
 1152: \begin{verbatim}/LET capaIDval=capa_id()
 1153: Your CAPA ID is /DIS(capaIDval). /DIS(newline)
 1154: The class name entered at login is /DIS(class()). /DIS(newline)
 1155: Your section number is /DIS(section()). /DIS(newline)
 1156: This is part of problem set /DIS(set()). /DIS(newline)
 1157: The current problem number is /DIS(problem()). /DIS(newline)
 1158: 
 1159: Output:
 1160: Your CAPA ID is 8659. 
 1161: The class name entered at login is nsc121s9. 
 1162: Your section number is 1. 
 1163: This is part of problem set 2. 
 1164: The current problem number is 2. 
 1165: \end{verbatim}
 1166: \\ \hline
 1167: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 1168: \index{name()}\index{student\_number()}{\tt name(), {\tt student\_number()}}& student name and student number. The
 1169: latter can be printed on quizzes when the student\_number is used for identification to
 1170: resolve ambiguities.\begin{verbatim}
 1171: /DIS(name()) /DIS(student_number())
 1172: \end{verbatim}
 1173: Output: Student, Jamie . A12345678
 1174: \\ \hline
 1175: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 1176: \index{open\_date()}\index{due\_date()}\index{answer\_date()}\index{due_day()}
 1177: {\tt  open\_date(), due\_date(), answer\_date()}& Problem set open date, due
 1178: date, and answer date. \begin{verbatim}
 1179: /DIS(open_date()) /DIS(newline)
 1180: /DIS(due_date()) /DIS(newline)
 1181: /DIS(answer_date()) /DIS(newline)
 1182: /DIS(due_day()) /DIS(newline)
 1183: 
 1184: Output:
 1185: Mon, May 3, 1999 at 08:00. \newline
 1186: Thr, May 6, 1999 at 08:00. \newline
 1187: Fri, May 7, 1999 at 08:00. \newline
 1188: Thr, May 6, 1999.
 1189: \end{verbatim}
 1190: \\ \hline
 1191: %************************************
 1192: \end{tabular}\end{center}}
 1193: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 1194: {\small 
 1195: \begin{center}\begin{tabular}{|p{2.9cm}|p{14.2cm}|}    \hline
 1196: { Functions}& Description, sample quizzer code and output \\ \hline
 1197: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 1198: \index{get\_seed()}\index{set\_seed()}{\tt get\_seed(), set\_seed()}
 1199: & get\_seed() returns the value of the seed for the random number generator. 
 1200: set\_seed() allows resetting the value of the random number generated seed to
 1201: an earlier value of the seed.
 1202: \begin{verbatim}
 1203: /LET seed1=get_seed()
 1204: /LET number=random(1,1000,1)
 1205: The current seed is: /DIS(seed1)
 1206: The random number was: /DIS(number)
 1207: 
 1208: /LET seed2=get_seed()
 1209: /LET number=random(1,1000,1)
 1210: The current seed is: /DIS(seed2)
 1211: The random number was: /DIS(number)
 1212: 
 1213: /LET any_variable=set_seed(seed1)
 1214: /LET seed3=get_seed()
 1215: /LET number=random(1,1000,1)
 1216: The current seed is: /DIS(seed3)
 1217: The random number was: /DIS(number)
 1218: 
 1219: Output: 
 1220: The current seed is: 1516840802 1582785437
 1221: The random number was: 727 
 1222: The current seed is: 539910159 1530382995 
 1223: The random number was: 671 
 1224: The current seed is: 1516840802 1582785437 
 1225: The random number was: 727 
 1226: \end{verbatim}
 1227: 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).
 1228: \\ \hline
 1229: %*************************************
 1230: \index{sub\_string(a,b,c)}{\tt sub\_string(a,b,c)}
 1231: & Allows instructor to retrieve part of a previously defined string (a=initial
 1232: string, b=place of starting character, c=length of substring).
 1233: \begin{verbatim}
 1234: /LET string1="Have a nice day."
 1235: /LET string2=sub_string(string1,8,4)
 1236: /DIS(string2)
 1237: 
 1238: Output:  nice \end{verbatim}
 1239: \\ \hline
 1240: \end{tabular}\end{center}}
 1241: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 1242: {\small 
 1243: \begin{center}\begin{tabular}{|p{3.1cm}|p{14.0cm}|}    \hline
 1244: { Functions}& Description, sample quizzer code and output \\ \hline
 1245: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 1246: %*************************************
 1247: \index{array[xx]}{\tt array[xx]}
 1248: & "xx" can be a variable or a calculation.  For example, for the array with name "NaMe":
 1249: \begin{verbatim}
 1250: /LET index=1
 1251: /WHILE ( index<10 )
 1252: /LET NaMe[index]=index*10.5
 1253: /LET index=index+1
 1254: /ENDWHILE
 1255: The value of NaMe[7] is /DIS(NaMe[7]:1f)
 1256: 
 1257: Output: The value of NaMe[7] is  73.5 \end{verbatim}
 1258: \\ \hline
 1259: %**************************************
 1260: %*************************************
 1261: \index{array\_max(Name)}{\tt array\_max(Name)}, 
 1262: \index{array\_min(Name)}{\tt array\_min(Name)}
 1263: & For example, for the array NaMe[xx] defined above:
 1264: \begin{verbatim}
 1265: maximum value of array element = /DIS(array_max(NaMe))
 1266: minimum value of array element = /DIS(array_min(NaMe))
 1267: 
 1268: Output: maximum value of array element = 94.5
 1269: minimum value of array element = 10.5 \end{verbatim}
 1270: \\ \hline
 1271: %*************************************
 1272: \index{array\_moments(B,A)}{\tt array\_moments(B,A)}
 1273: & The moments of array A[] are put into array B[i] with i=0 to 4.
 1274: 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]
 1275: \begin{verbatim}
 1276: /LET elements=array_moments(MMT,NaMe)
 1277: Displaying the moments:
 1278: number of elements=/DIS(MMT[0]:2f)
 1279: mean=/DIS(MMT[1]:2f)
 1280: variance=/DIS(MMT[2]:2f)
 1281: skewness=/DIS(MMT[3]:2f)
 1282: kurtosis=/DIS(MMT[4]:2f)
 1283: 
 1284: Output:  Displaying the moments:
 1285: number of elements=9
 1286: mean=52.50
 1287: variance=826.87
 1288: skewness=0.00
 1289: kurtosis=-1.60 \end{verbatim}
 1290: \\ \hline
 1291: %*************************************
 1292: \index{init\_array(Name)}{\tt init\_array(Name)}
 1293: & 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:
 1294: \begin{verbatim}
 1295: Current value of NaMe[5] = /DIS(NaMe[5]:1f)
 1296: /LET deletd=init_array(NaMe)
 1297: New value of NaMe[5] = /DIS(NaMe[5]:1f)
 1298: Number of array elements deleted = /DIS(deletd)
 1299: 
 1300: Output: Current value of NaMe[5] = 52.5
 1301: New value of NaMe[5] = VAR "NaMe[5]" NOT DEFINED!
 1302: Number of array elements deleted = 9  \end{verbatim}
 1303: \\ \hline
 1304: %*************************************
 1305: \end{tabular}\end{center}}
 1306: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 1307: {\small 
 1308: \begin{center}\begin{tabular}{|p{4.9cm}|p{12.2cm}|}    \hline
 1309: { Functions}& Description, sample quizzer code and output \\ \hline
 1310: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 1311: \index{random\_normal()}
 1312: \index{random\_beta()}
 1313: \index{random\_gamma()}
 1314: \index{random\_exponential()}
 1315: \index{random\_poisson()}
 1316: \index{random\_chi()}
 1317: \index{random\_noncentral\_chi()}
 1318: \tt{random\_normal(,,,,)}
 1319: \tt{random\_beta(,,,,)}
 1320: \tt{random\_gamma(,,,,)}
 1321: \tt{random\_exponential(,,,)}
 1322: \tt{random\_poisson(,,,)}
 1323: \tt{random\_chi(,,,)}
 1324: \tt{random\_noncentral\_chi(,,,,)}
 1325: &
 1326: \tt{random\_normal(return\_array,item\_cnt,seed,av,std\_dev)} \newline
 1327: \tt{random\_beta(return\_array,item\_cnt,seed,aa,bb)} \newline
 1328: \tt{random\_gamma(return\_array,item\_cnt,seed,a,r)} \newline
 1329: \tt{random\_exponential(return\_array,item\_cnt,seed,av)} \newline
 1330: \tt{random\_poisson(return\_array,item\_cnt,seed,mu)} \newline
 1331: \tt{random\_chi(return\_array,item\_cnt,seed,df)} \newline
 1332: \tt{random\_noncentral\_chi(return\_array,item\_cnt,seed,df,xnonc)} \newline
 1333: 
 1334: Generate item\_cnt of random numbers according to the particular distribution 
 1335: with the specified parameters and seed and store them in the array named return\_array.
 1336: \\ \hline
 1337: Sample Code&Sample Code for \tt{random\_poisson(,,,)}  and \tt{random\_normal(,,,,)} is shown on the next page.
 1338: \\ \hline
 1339: %*************************************
 1340: \end{tabular}\end{center}}
 1341: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 1342: {\small 
 1343: \begin{center}\begin{tabular}{|p{3.3cm}|p{13.8cm}|}    \hline
 1344: %{ Functions}& Description, sample quizzer code and output \\ \hline
 1345: %*************************************
 1346: \index{random\_poisson(,,,)}{\tt random\_poisson(,,,)}
 1347: & FORM: random\_poisson(return\_array,item\_cnt,seed,av) \\
 1348: & Array name and 3 parameters needed. Below, the return\_array is called ``RET":
 1349: \begin{verbatim}/LET dleted=init_array(RET) // initialize array "RET"
 1350: /LET myseed=777  // could be = random(1,10000)
 1351: /LET count=10
 1352: /LET average=2.2
 1353: /LET samples=random_poisson(RET,count,myseed,average)
 1354: samples=/DIS(samples); Note `samples' it is the same as `count'
 1355: /LET j=0
 1356: /WHILE (j <10)
 1357:    RET[/DIS(j)] = /DIS(RET[j]) 
 1358:   /LET j=j+1
 1359: /ENDWHILE
 1360: OUTPUT: samples=15; Note `samples' it is the same as `count'
 1361:    RET[0] = 3      RET[1] = 0 
 1362:    RET[2] = 3      RET[3] = 1 
 1363:    RET[4] = 2      RET[5] = 4 
 1364:    RET[6] = 2      RET[7] = 2 
 1365:    RET[8] = 1      RET[9] = 2 
 1366: \end{verbatim}
 1367: \\ \hline
 1368: %**************************************
 1369: %*************************************
 1370: \index{random\_normal(,,,,)}{\tt random\_normal(,,,,)}
 1371: & FORM: random\_normal(return\_array,item\_cnt,seed,av,std\_dev) \\
 1372: & Array name and 4 parameters needed. (return\_array called ``RET")
 1373: \begin{verbatim}/LET dleted=init_array(RET) // initialize array "RET"
 1374: /LET myseed=555  // could be = random(1,10000)
 1375: /LET count=10
 1376: /LET average=6.2
 1377: /LET stddev=2
 1378: /LET samples=random_normal(RET,count,myseed,average,stddev)
 1379: samples=/DIS(samples); Note `samples' it is the same as `count'
 1380: /LET j=0
 1381: /WHILE (j <10)
 1382:   /LET RETB[j] = roundto(RET[j],2) // This array is rounded to 2 places
 1383:    RET[/DIS(j)] = /DIS(RET[j]:4f) and RETB[/DIS(j)] = /DIS(RETB[j]:2f)
 1384:   /LET j=j+1
 1385: /ENDWHILE
 1386: OUTPUT: samples=15; Note `samples' it is the same as `count'
 1387:    RET[0] = 2.9195 and RETB[0] = 2.92
 1388:    RET[1] = 6.4934 and RETB[1] = 6.49
 1389:    RET[2] = 7.2427 and RETB[2] = 7.24
 1390:    RET[3] = 7.0054 and RETB[3] = 7.01
 1391:    RET[4] = 7.1111 and RETB[4] = 7.11
 1392:    RET[5] = 8.8491 and RETB[5] = 8.85
 1393:    RET[6] = 6.9555 and RETB[6] = 6.96
 1394:    RET[7] = 9.7349 and RETB[7] = 9.73
 1395:    RET[8] = 8.1034 and RETB[8] = 8.10
 1396:    RET[9] = 6.8346 and RETB[9] = 6.83  \end{verbatim}
 1397: \\ \hline
 1398: %**************************************
 1399: %*************************************
 1400: \end{tabular}\end{center}}
 1401: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 1402: \clearpage
 1403: 
 1404: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>