Operations, functions, and variables

The Mastering series uses algebraic expression matching to determine if student submissions match the answer you coded. If the correct answer is 0.5*m*v^2 and a student enters v*m*(v/2), the answer is graded as correct.

When you enter a wrong answer response for a symbolic question, the program matches any expression a student submits that is algebraically equivalent to that response. If the wrong answer is a number, then it matches any student-submitted number within the specified tolerance.

Notation

Code symbolic answers using standard infix notation, shown below.

Important: Always use parentheses and multiplication signs in your answers. For example, when coding the product of "a" and "(b+c)", the correct syntax is:

a*(b+c)

not

a(b+c)

The latter indicates that a is a function of b+c.

Arithmetic operators

The Mastering series recognizes:

Order of Operations

Note the following as you code your answers:

Randomized Variables

An answer of type solutionSymbolic may be a function of any or all of the randomized variables as defined using the varDefinition element.

Note: A correct answer cannot be a combination of symbolic and randomized symbolic. For example, you cannot have a correct answer of type 2*sin(theta)*cos(n*theta), where theta is a fixed symbol and n is a randomized variable.

Recognized Functions

You can add the functions below to symbolic answers.

Important: Functions are case sensitive.

Arguments in radians or degrees: The arguments of trigonometric functions are in radians, not degrees. Alternatively, you can set the arguments to degrees in the item attributes. When the answer should be in degrees, be sure to specify this in the problem statement. (Otherwise, students expect that they should be answering in radians.)

For this special function Enter this from your keyboard What the student types
absolute value abs(x) |
arccosine acos(x) arccos(x), acos(x), or cos^-1(x)
arcotangent acot(x) arccot(x), acot(x), or cot^-1(x)
arcosecant ascs(x) arcscs(x), ascs(x) or csc^-1(x)
arcsecant asec(x) arcsec(x), asec(x), or sec^-1(x)
arcsine asin(x) arcsin(x), asin(x), or sin^-1(x)
arctangent atan(x) arctan(x), atan(x), or tan^-1(x)
cosine cos(x) cos(x)
cotangent cot(x) cot(x)
cosecant csc(x) csc(x)

e raised to a power

Note: Avoid using the solutionSymbolic or solutionSymbolicSet answer type for large positive or negative exponents, such as exp(37000) or exp(-37000). Currently Mastering doesn’t always evaluate large exponents correctly. Instead, use another answer type, such as a multiple choice (solutionMultipleChoiceRadio/Dropdown or solutionMultipleSelect).

e^(x) or

exp(x)

e^x or exp(x)
natural logarithm (base e) ln(x) ln(x)
common logarithm (base 10) log(x) log(x)
secant sec(x) sec(x)
sine sin(x) sin(x)
square root sqrt(x) \sqrt
tangent tan(x) tan(x)

 

The following functions are available in Mastering for authors, but are not needed by students.

Function Use this format Purpose and example
ceiling ceil(value)

Purpose:
Rounds a value up to the nearest integer.

 

Example:
ceil(6.4) returns 7

floor floor(value)

Purpose:
Rounds a value down to the nearest integer.

 

Example:
floor(8.6) returns 8

ifthenelse ifthenelse(test,true_value,false_value)

Purpose:
Returns one of two values, depending on the result of a logical test.

 

Example:
ifthenelse(x>y,x,y) returns x if x is larger; otherwise it returns y.

integer int(value) Purpose:
Same as the floor function (rounds a value down to the nearest integer).

 

Example:
int(13.7) returns 13

random rand(range-start,range-end,exponent) Purpose:
Generates a random number within a specified range, optionally rounded to a specific power of 10.

 

Example:
rand(10,100,1) randomly returns 10, 20, 30, ...100.
The default value for exponent is 0. That is, the value returned is rounded to the nearest integer.

round round(value, exponent) Purpose:
Rounds a value to a specific power of 10.

 

Example:
round(1.2345,-3) returns 1.235

significant digits sigdig(value, exponent) Purpose:
Rounds a value to a specific number of significant digits.

 

Example:
sigdig(1.2345,3) returns 1.23

 

See also:

var tag examples