6.22 Details on Using Algorithmic Variables - Maple T.A. 2016 Help
Maple T.A. Online Help

Select your version: Maple T.A. 2017 | Maple T.A. 2016 | Maple T.A. 10

6.22 Details on Using Algorithmic Variables

The Answer Field Evaluation and Requirements

The answer field specifies internal directives, or instructions to the system for how to grade the question. It operates like a command-line statement when processed by the system.

The answer field accepts only values that can be system-evaluated: numbers, formulas, algorithmic variables, or numbers and/or formulas with required physical units.

The system recognizes:

  • Equivalent numeric and algebraic expressions
  • Equivalent standard physical units
  • Scientific notation
  • The ? operator as a representation of a margin of error. The answer:

(3.75 ? 0.05) kg grades all responses in the range 3.70 to 3.80 kg (inclusive) correct.

Note: You cannot use the ? operator in the numeric answer (answer.num field) for a numeric question. You must use the specialized tolerance fields.

Variable definitions must reduce to one of the above.

You can round a variable value to any number of significant digits, and then specify the variable as the answer.

Controlling Display of Numbers within Questions

All random numbers generated by the system from variable definitions are floating-point variables. By default, they are expressed to about 8 significant digits.

To control the display of numeric variables, enclose expressions in an int() statement to make them integers (for example, $m=int(14.5*5);), or in double quotes "" to make them strings (for example, $s="380";).

You can also control the appearance of numeric variables by enclosing random number generating statements and arithmetic operations with decimal(n,(statement)), to express the result to n decimal places, or by using the sig(n,(statement)) structure to express the result to n significant digits.

See Also:

Random Integer Generation rint(n), rint(m, n), rint(m, n, k)

decimal(n, x), sig(n, x), int(x)

Variables within Variable Statements

You can use variables as arguments in variable definition statements.

Since the algorithm generation works linearly, you must define variables before referencing them in other variable definition statements (or control sequences).


      $ans=sig($n,  $x)
  Express the number $x to $n significant places.

See Also:

Controlling Answer Tolerance

decimal(n, x), sig(n, x), int(x)

rand(m, n), rand(m, n, k)

Random Integer Generation rint(n), rint(m, n), rint(m, n, k)

Displaying the $ (Dollar Sign) in Questions

The use of the $ is reserved for variable definitions in algorithms in the Maple T.A. question syntax.

To display a $ character in the text of your question, use:


Displaying the Backslash Symbol in Questions

The use of the backslash character is reserved in the Maple T.A. system question syntax. To include a \ character in the text of your question, use:


Text Strings in Variable Statements

Statements defining variables can also include text strings. Strings must be enclosed in double quotes "".


       $animal=switch(rint(2),  "cat", "dog");
       $mass=if(int(eq("$animal",  "cat")), rand(2,15,2), rand(10,30,2));
A $mass kg $animal is running at $velocity m/s. What is its kinetic energy?
qu.4.1.answer= (1/2)$mass * $velocity^2

In the test for the type of animal in the definition of $mass, it is required that the variable $animal be enclosed in quotes.

Note: The strings in the example above appear only as arguments to functions. It is recommended that you do not mix strings and numbers in expressions.