This page was last updated on September 14, 2022. To view the latest list of functions, open a question in authoring, click the information icon in the lower left, and select "Reference".
Functions marked with † can be used by students in input. Functions marked with ‡ normally can't, but may be allowed by the author on a per-questions basis. Use question_settings to change which functions are allowed in input.
random(low, hi, step)
Returns a random number in the range [low, hi] in increments of step. Default step is 1.
random_exclude(low, high)
Returns a random number in the range [low, high] in increments of step, respecting excluded numbers.
Named Argument: step step size used to increment low. Defaults to 1
Named Argument: excludes numbers to exclude
random_normal(the_mean, sigma, d)
Returns a sample from a normal distribution with the given mean and standard deviation, rounded to d decimal places. Default d is 2.
random_item(the_list)
Returns a random item from a list.
random_pythagorean_triple(max)
Returns a random pythagorean triple with a maximum side up to max, which defaults to 100. Includes non-primitive triples like {6,8,10} which is 2*{3,4,5}.
unique_randoms(n, low, high, step)
Returns n unique random numbers in the range [low, high] in increments of step.
randint(low, hi) - use random instead, to be consistent
Returns a random integer in the range [low, hi].
random_decimal(low, hi, n) - use random instead, to be consistent
Returns a random number in the range [low, hi] with up to n decimal places.
exclude(rand, ex1, ex2, ...) - use random_exclude instead, because exclude returns Error when it hasn't found a working value after 10 tries
Ensures that a random expression rand does not return specific values
‡not(x)
Logical negation
‡and(a, b, ...)
Logical and
‡or(a, b, ...)
Logical or
make_set(the_list)
Return a list of unique numbers from the input list of numbers
set_union(list_one, list_two)
Return a list of unique elements from the union of the two lists
set_intersection(list_one, list_two)
Return a list of unique numbers from the intersection of the two lists
set_difference(list_one, list_two)
Return a list of unique elements from the list_one minus list_two
†sqrt(x)
Returns the square root of x.
†nth_root(n, x)
Returns the nth root of x.
‡exp(x)
Returns e^x.
†ln(x)
Natural logarithm
†log10(x)
Logarithm base 10
†log(x)
Logarithm with the base set by set_log_base(). Defaults to base e.
†log_b(base, argument)
Logarithm with base of your choice.
sgn(expression)
Returns the sign of the expression
†abs(x)
Returns the absolute value of a real number. If x is complex, returns the magnitude.
‡ceiling(x)
Returns the smallest integer not less than x.
‡floor(x)
Returns the largest integer not greater than x.
‡mod(a, b)
Returns the remainder of a/b. May be positive or negative
fibonacci(n)
The nth Fibonacci number. Range: 0 ≤ n ≤ 71.
prime(n)
Returns the nth prime number.
prime_factorization(n)
Returns the prime factorization of n.
prime_factors(n)
Returns a list of the prime factors of n. If a prime factor divides n more than once, it will appear in the list multiple times.
factor(p, x, ...)
Factors a polynomial. If omitted, the variable defaults to x. Multiple variables are also supported: factor(p,x,y) factors p over x and then over y.
nroots(p, x)
Returns all of the roots, both real and complex, of polynomial p in x. The roots are computed numerically. Does not work on polynomials with decimal coefficients.
†factorial(x)
Returns the product of all integers less than or equal to x but greater than or equal to 1. You can also use x!
†choose(n, k)
Returns the number of ways of picking a set of k items out of n distinct items. Previews as \binom{n}{k}.
†nCr(n, r)
Returns the number of ways of picking a set of r items out of n distinct items. Previews as _{n} C _{r}.
nPr(n, r)
Returns the number of ways of picking a sequence of r items out of n distinct items. Previews as _{n} P _{r}.
‡gcd(a, b, ...)
Greatest common divisor
‡lcm(a, b, ...)
Least common multiple
identity_matrix(n)
Returns an n x n identity matrix.
diagonal_matrix(values)
Returns a square matrix with values along the main diagonal and 0s elsewhere.
‡transpose(matrix)
Transpose a matrix.
†determinant(matrix)
Find the determinant of a matrix
†inverse(matrix)
Find the inverse of a matrix
†adjoint(matrix)
Find the adjoint of a matrix
‡matrix_multiply(matrix_a, matrix_b)
Multiply two matrices.
matrix_a a rectangular matrix of dimensions m x n
matrix_b a rectangular matrix of n x p
‡cross_product(u, v)
Returns the cross product of u and v.
‡cross(u, v) (Deprecated)
Deprecated alternate name of cross_product
dot_product(u, v)
Returns the dot product of u and v.
†union(s, t, ...)
Returns the union of intervals s and t.
interval_contains(interval, value)
Returns true if the value is contained in the interval
interval an interval or union of intervals
value a numeric value
min(a, b, ...)
Returns the minimum item from a list of numbers.
min(the_list)
Returns the minimum item from a list of numbers.
median(a, b, ...)
Returns the median of a list of numbers.
median(the_list)
Returns the median of a list of numbers.
max(a, b, ...)
Returns the maximum item from a list of numbers.
max(the_list)
Returns the maximum item from a list of numbers.
five_number_summary(the_list, [quartile_method])
Returns the five-number summary of a list of data. The result will be a list ordered as: [Minimum, First Quartile, Median, Third Quartile, Maximum]. Possible methods for calculating the quartiles are "exclusive", "inclusive", "CDF", and "excel" (the default).
mean(a, b, ...)
Returns the mean of a list of numbers.
mean(the_list)
Returns the mean of a list of numbers.
mode(a, b, ...)
Returns the mode(s) of a list of numbers.
mode(the_list)
Returns the mode(s) of a list of numbers.
population_standard_deviation(numbers)
Returns the standard deviation for the list of data, using the population formula.
sample_standard_deviation(numbers)
Returns the standard deviation for the list of data, using the sample formula.
percentile(p, the_list)
Returns the pth percentile of a list of numbers, where p is in [0, 1]
normal_cdf(value, mean, standard_deviation)
Normal cumulative distribution function. Returns the probability that a measurement from the normal distribution with the given mean and standard deviation is less than value.
normal_cdf(z_score)
Normal cumulative distribution function. Returns the probability that a measurement from the standard normal distribution is less than z_score.
real(z)
Returns the real part of a complex number
imag(z)
Given a complex number, returns the coefficient on i.
‡conj(z)
Returns the complex conjugate of z.
arg(z)
Returns the angle between the positive real axis and the vector represented by z on the complex plane, in the range [-pi, pi).
polar(z)
Converts a complex number to polar form.
rect(z)
Converts a complex number to rectangular form.
All trig functions operate in radians.
†sin(t)
†cos(t)
†tan(t)
†csc(t)
†sec(t)
†cot(t)
†arcsin(x)
†arccos(x)
†arctan(x)
†arccsc(x)
†arcsec(x)
†arccot(x)
†sinh(t)
†cosh(t)
†tanh(t)
†csch(t)
†sech(t)
†coth(t)
†arcsinh(x)
†arccosh(x)
†arctanh(x)
†arccsch(x)
†arcsech(x)
†arccoth(x)
reduce_angle(angle)
Returns the angle coterminal to angle in the range [0, 2pi). Returns radians when given radians and degrees when given degrees.
to_degrees(radians)
Converts a radian value to an expression in degrees: 2 pi -> 360 deg
to_radians(degrees)
Converts a degree expression to a value in degrees: 360 deg -> 2 pi
* See Complex Numbers for changing between rectangular and polar coordinates
†sum(i, j, k, f)
Returns the sum of all f for i=j through k.
‡product(i, j, k, f)
Returns the product of all f with i=j through k.
taylor(f, x, n, a)
Returns the nth-degree Taylor expansion of f(x) around x=a.
‡derivative(f, x)
Returns the partial derivative of f with respect to x. Displays as df/dx
‡partial_derivative(f, x)
Returns the partial derivative of f with respect to x. Displays as ∂f/∂x
‡integral(f, x)
Indefinite integral.
‡defint(f, x, a, b, ...)
Definite integral. Returns the definite integral of f with respect to x evaluated from a to b. The argument list may be extended for multiple integrals.
question_settings(settings_id)
Specify the settings for the question
settings_id: A string representing the type of course, which will determine which functions will be shown on the toolbar and allowed in student input. Options: "Default", "Everything", "Quantitative Reasoning", "Algebra", "Calculus"
Named Argument: allow Optionally specify additional functions to allow in student input
Named Argument: disallow Optionally specify additional functions to disallow in student input
Named Argument: allow_student_percent_sign If true, 5% will be valid student input
Named Argument: allow_student_degree If true, 60deg will be valid student input
Named Argument: allow_student_pi If true, 2pi will be valid student input
Named Argument: allow_scientific_e_notation If true, 3e4 parses as 3*10^4 in student input
Named Argument: manual_grading_weight Sets the weight for the manually graded part of this question, [0, 1]
Named Argument: preserve_fractional_exponents If true, 3^(1/2) will be computed as a fraction not a radical
Named Argument: multiplication_symbol The symbol shown for multiplication. Defaults to "\cdot", but can be changed to "\times"
math_funcs(functions...)
Declares names that should be treated as functions. For more details, see the Custom Mathematical Functions page.
math_func_settings(name)
Declare the rendering for a math_func
name The name of the function
Named Argument: display Custom LaTeX to use when rendering the math function. Use "#n" to represent the nth argument.
Named Argument: display_name Custom LaTeX to use when rendering the function name.
math_sym()
Declare a custom symbol
Named Argument: display A string of LaTeX to use when rendering the symbol.
Named Argument: value The value the symbol will have when used in calculations.
Named Argument: private If true, students will not be able to use the symbol in input
set_log_base(base)
Sets a positive real number as the base to use for the log() function. Without setting, log() will use e as the base. This is set globally for the question, so it is strongly recommended to be the first statement of your question code.
Some of the following variables have values stored to them by default. Any of these can be overwritten, so be careful.
true
Truth value returned by logical and is_* functions. Treated as 1 in numeric calculations. Displays as true
false
Truth value returned by logical and is_* functions. Treated as 0 in numeric calculations. Displays as false
i
The square root of -1. Displays as i
pi
The circle constant, 3.14159... Displays as π
e
Euler's number, 2.71828... Displays as e
deg
The value needed to convert degrees to radians, pi/180. Displays as °
%
The value 1/100. Displays as %
infinity
Does not store a default value, so infinity*0 = 0, infinity^0 = 1, etc. Displays as ∞
dne
Does not exist. Does not store a default value, but is the same regardless of capitalization, so dne, DNE, dNe, etc are equal. Displays as DNE
none
Does not store a default value, but is the same regardless of capitalization, so none, NONE, nOnE, etc are equal. Displays as None
alpha, beta, gamma...
Lowercase Greek letters for display. They do not store default values (except pi). Display as α, β, γ...
Delta, Gamma, Lambda, Omega, Phi, Pi, Psi, Sigma, Theta, Upsilon, Xi
Uppercase Greek letters for display. They do not store default values. Display as Δ, Γ, Λ, Ω, Φ, Π, Ψ, Σ, Θ, ϒ, Ξ
compute(expression)
Evaluates an expression using the CAS.
simplify(expression)
Simplifies an expression using the CAS.
expand(e, x)
Partial fraction expansion. expand(1/(x^3 + x^2), x) -> 1/x^2 - 1/x + 1/(x+1)
expand(expression)
Expands Math Functions into a flat expression, but does not evaluate the result.
function_name(expression)
If expression is a function definition, returns the name of the function. Otherwise, it returns the empty string.
apply(function, arguments...)
Evaluates a student supplied function with the supplied arguments
subst(e, var=value, ...)
Variable substitution. subst(a+b, a=1, b=2) -> 1+2
round(n, precision)
Rounds n to the given precision, which defaults to 1 and must be a power of ten. For example, round(345.05, 100) -> 300, round(345.05, 0.1) -> 345.1, round(345.05) -> 345.
combine_fractions(x)
Returns the expression with everything over a common denominator.
rationalize(x)
Deprecated alternate name of combine_fractions. Will be removed soon.
float(x)
Converts rational numbers and integers to floating point values.
concat(strings...)
concatenates strings
list(items...)
Create a list with specific delimiters: list(...), list(...], list[...), list[...], list<...>, or list{...} You can not use a > inequality expression inside list<...>. To create a delimiterless list, use the syntax [item1, item2, items...].
fill_list(n, expression)
Create a list by evaluating expression n times.
nth_item(n, the_list)
Returns the nth item of a list
list_get(the_list, i, j, ...)
Returns the item from the multi-dimensional list at indices (i,j,...).
item_count(the_list)
Returns number of items in a list. If the argument is not a list, returns -1.
list_contains(the_list, compare_expression)
Returns true if the list contains an element that makes the provided expression evaluate to true. For example, list_contains([1,2,3], is_equivalent(4/2, item)) returns true
compare_expression the expression may have the variables item and index that will be replaced with the item and its index in the list during evaluation
list_find(the_list, compare_expression)
Returns the indices of list elements that make the provided expression evaluate to true. Otherwise, returns an empty list. Uses compare_expression to determine if items are the same.
compare_expression the expression may use the variables item and index that will be replaced with the list item and its index during evaluation
has_same_items(expected_list, given_list, compare_expression)
Returns true if there is a one-to-one pairing of items in the two lists that makes the compare_expression evaluate to true. has_same_items is an expensive function and should only be used with relatively short lists. Uses is_equal if compare_expression isn't specified.
compare_expression the expression may have the variables item1 and item2 that will be replaced with the items from the first and second list during evaluation
list_delimiters(the_list)
Returns the delimiters used to create a list. list_delimiters(list<a,b>) => ["<", ">"]
has_same_delimiters(first_list, second_list)
Returns true if both provided lists have the same delimiters. For example: has_same_delimiters(list[1,2], list[3,4]) => true has_same_delimiters(list(1,2), list<3,4>) => false
is_same_list(expected_list, given_list, compare_expression)
Checks if two lists have the same items in the same order. It uses compare_expression to determine if items are the same. Uses is_equal if compare_expression isn't specified. List delimiters must also match for this function to return true.
compare_expression The expression used to compare items in each list. Use the variables "item1", "item2", and "index" to refer to the items from the first and second lists respectively and their index.
list_concat(lists...)
concatenates lists
sort(the_list, sort_expression)
Returns a copy of the list sorted ascending numerically then lexigraphically by the string representation of the list item. That is, all numbers come before non-numbers, sorted low to high, then everything else is sorted based on the alphabetic order of its stringified form. When sort_expression is provided, it sorts by the float returned from sort_expression.
sort_expression Optional function that returns a float for sorting least to greatest. The variables "index" and "item" can be used. For example: sort([1, 2, 3, 4], -item) will return the list [4, 3, 2, 1].
list_reverse(the_list)
Returns a copy of the list reversed. If the start and end delimiters differ, they will be reversed. e.g. list_reverse(list(1,2]) results in list[2,1)
list_shuffle(the_list)
Returns a shuffled list
list_slice(the_list, low, [high])
Given a list and one index, returns a slice of the list, from given index (inclusive) to the end of the list. For example: list_slice([3,5,6,8,7], 2) returns [5,6,8,7].
Given a list and two indices, returns a slice of the list, from the first index to the second (both inclusive). For example: list_slice([3,5,6,8,7], 2, 4) returns [5,6,8].
list_remove(the_list, index)
Return a copy of the list without the item at index. You can also list multiple indices to remove multiple items.
list_filter(the_list, filter_expression)
Returns a filtered list containing the elements where the provided expression evaluates to true.
filter_expression the expression may have the variables item, index that will be replaced with the items and their index in the list during evaluation
list_transform(the_list, transform_expression)
Returns a new list containing a one-to-one map of the elements to the provided expression.
transform_expression the expression may use the variables item, index that will be replaced with the items and their index in the list during evaluation
list_replace(the_list, new_value, i, j, ...)
Returns a copy of the list with the item at (i, j, ...) replaced with new_value.
list_flatten(the_list)
Returns a copy of the_list with sub-lists flattened recursively to the specified depth.
Named Argument: depth depth to flatten to, defaults to 1
sum(the_list)
Sum the items in a list.
product(the_list)
Multiply the items in a list.
*See Mathematical > Statistics and Mathematical > Set operations for more
format_decimal(value, max_digits, min_digits)
Formats a number as a decimal with at most N fractional digits. Default N is 6. An additional third parameter can be passed that allows for trailing zeros.
Formats a number as a decimal with a number of fractional digits between max_digits and min_digits. The defaults are 6 and 0.
format_decimal(4, 3) => "4"
format_decimal(4, 3, 1) => "4.0"
format_scientific(value, max_digits, min_digits)
Formats a number in scientific notation with a number of fractional digits between max_digits and min_digits. The defaults are 6 and 0.
format_percent(value, max_digits, min_digits)
Formats a number as a percentage with a number of fractional digits between max_digits and min_digits. The defaults are 0 and 0.
format_percent(0.8, 3) => "80%"
format_percent(0.8, 3, 3) => "80.000%"
format_currency(value, currency_code, display_mode)
Formats a number as currency with the given currency code. format_currency(6.777, 'GBP') => "£6.78". For more details, see the Currency Formatting page.
format_mixed(value, denominator)
Evaluates an expression and formats the result as a mixed number
denominator Denominator to use instead of reducing the fraction
format_odds(odds_list OR probability_fraction)
Formats a list of numbers, or a fraction into an odds ratio.
format_odds([8, 5]) => "8:5"
format_odds(8/13) => "8:5"
format_piecewise(matrix)
Format a matrix as a piecewise function
matrix a 2x2 matrix with rows of the form [function, condition] (example: [[-x, x < 0], [x, x >= 0]])
spell_out_number(n)
Returns n spelled out in English words
See the Plotting page for info about Omaha's native plotting functions. Below is information about plotting with other tools.
jsx_graph(id, args...)
Generates a JSXGraph widget. This value must be saved in a variable. Referencing the variable in your prompt displays the widget. For more details, see the JSX Widgets page.
id unique identifier for the graph (string)
args ... arguments passed to the custom scripts render function
geometric_construction(id)
Renders a static geometric construction
Named Argument: width
Named Argument: height
desmos_calculator(id, args...)
Renders a Desmos calculator widget
id unique identifier for the graph (string)
args... expressions to supply to the calculator
Named Argument: width
Named Argument: height
Named Argument: x_min
Named Argument: x_max
Named Argument: y_min
Named Argument: y_max
Named Argument: lock_viewport
basic_simplify(expression)
Performs basic simplifications on a randomized expression to prepare it for display. Converts a+-b to a-b, handles addition or multiplication by 0, and multiplication, division, or exponents of 1. Also removes extra parenthesis.
align_equations(equation, ...)
Displays equations on separate lines with the operators aligned. When called with a single expression containing multiple comparison operators (such as a=b=c), align_equations will split lines at each comparison operator after the first one. Skips repeated lines, so align_equations(a = b = b) and align_equations(a = b, a = b) both display a = b
table(table)
Generate an html table from a matrix (list of lists). The first row of the matrix must be the table headers.
table_transpose(the_matrix)
Returns a copy of the 2D Table transposed
walkthrough(matrix)
Formats a two-column matrix as a step-by-step table.
Named Argument: alignment Options: "left", "right", "left-right", or "right-left"
latex(string)
Interprets a string as LaTeX to display.
html(html)
Interprets a string as HTML to display.
capitalize(string)
Return a string where the first letter is capitalized.
multiple_choice(options...)
Creates a multiple choice input widget from options
options... answer(), distractor(), option(), or allow_multiple
Named Argument: allow_multiple Enable multiple select
Named Argument: shuffle Disable shuffle for all options
answer(value, feedback)
Creates a correct option for a multiple choice widget.
value value to show the student.
feedback feedback to show if this option is selected.
distractor(value, feedback)
Creates an incorrect option for a multiple choice widget.
value value to show the student.
feedback feedback to show if this option is selected.
option(correct, value, feedback)
Creates an option for a multiple choice widget.
correct Whether this is a correct option. Can be an expression, e.g. exponent < 0
value value to show the student.
feedback feedback to show if this option is selected.
Named Argument: correct_feedback feedback to show if this option is correct and is selected.
Named Argument: incorrect_feedback feedback to show if this option is incorrect and is selected.
no_shuffle(option)
Disables shuffling the order for a multiple choice option.
input_dropdown(options)
Creates a dropdown input widget from a list of options.
options a list of answers, distractors, and options
Each of the following functions generates an input box for entering an expression. This value must be saved in a variable. Referencing the variable in your prompt displays the input box. Referencing the variable in your code evaluates to the expression the student has entered.
Most input boxes can be put inline by including the named argument inline := true. You can set the number of characters that should fit into an inline input using the named argument width.
input_expr("label", "prefix", "suffix")
Generates an expression input box with a label, prefix, and/or suffix.
"label" Text label for the input. Defaults to "Expression". Should not be combined with prefix.
"prefix" Text to show inside the input box before student entered text, e.g. "$". Should not be combined with a label
"suffix" Text to show inside the input box after student entered text, e.g. "inches".
input_list("label", "prefix", "suffix")
Generates a list input box with a label, prefix, and/or suffix.
"label" Text label for the input. Defaults to "". Should not be combined with prefix
"prefix" Text to show inside the input box before student entered text, e.g. "$". Should not be combined with a label
"suffix" Text to show inside the input box after student entered text, e.g. "inches".
input_matrix("label")
Generates a matrix input box
"label" Text label for the input. Defaults to "Matrix".
Named Argument: augmented Render as an augmented matrix.
input_interval("label", "prefix", "suffix")
Generates a set input box with a label, prefix, and/or suffix.
"label" Text label for the input. Defaults to "Interval". Should not be combined with prefix
"prefix" Text to show inside the input box before student entered text, e.g. "$". Should not be combined with a label
"suffix" Text to show inside the input box after student entered text, e.g. "inches".
input_ratio("label")
Generates a ratio input box
"label" Text label for the input. Defaults to ""
Named Argument: is_odds Whether to treat input as an odds ratio. When false, a:b is treated as a/b. When true, a:b is treated as a/(a+b).
input_decimal("label", "prefix", "suffix")
Generates an input that only accepts decimal values
"label" Text label for the input. Defaults to "Interval". Should not be combined with prefix
"prefix" Text to show inside the input box before student entered text, e.g. "$". Should not be combined with a label
"suffix" Text to show inside the input box after student entered text, e.g. "inches".
These are similar to the standard inputs, but allow students to use special notation for geometry.
input_geometry_expr("label", "prefix", "suffix")
Generates an expression input box with a label, prefix, and/or suffix.
"label" Text label for the input. Defaults to "Expression". Should not be combined with prefix.
"prefix" Text to show inside the input box before student entered text, e.g. "$". Should not be combined with a label
"suffix" Text to show inside the input box after student entered text, e.g. "inches".
input_geometry_list("label", "prefix", "suffix")
Generates a list input box with a label, prefix, and/or suffix.
"label" Text label for the input. Defaults to "". Should not be combined with prefix
"prefix" Text to show inside the input box before student entered text, e.g. "$". Should not be combined with a label
"suffix" Text to show inside the input box after student entered text, e.g. "inches".
input_essay(placeholder)
Generates an input box for answering a free response question
placeholder a string to display in the box before the student has started typing
jsx_input(id, args ...)
Generates a JSXGraph input widget. Returns the list that the custom script passes to derivita.saveInput(). For more details, see the JSX Widgets page.
id unique identifier for the graph (string)
args ... arguments passed to the custom scripts render function
input_geometric_construction(id)
Renders a geometric construction for the student to complete
Named Argument: width
Named Argument: height
input_decimal_inline() (Deprecated)
Use input_decimal(inline := true) instead.
input_odds() (Deprecated)
Use input_ratio(is_odds := true) instead.
For more details on the differences between these functions, see the Equivalence Testing page.
Note 1: Calling any of these functions increments the max score, and if the function returns true, increments the earned score.
Note 2: feedback refers to an optional string argument that will display on the input box when the function returns false.
assert_valid(given)
Checks that the student entered a valid expression.
assert_equal(expected, given, feedback)
Checks that two expressions are the same. This does not evaluate anything, so 1 + 1 ≠ 2 and sin(0) ≠ 0.
assert_equivalent(expected, given, feedback)
Checks symbolically for algebraic equivalence of expressions, equations or lists.
assert_simplified_rational(expected, given)
Checks for algebraic equivalence of expressions, requiring the answer to be a simplified rational number (an integer, fraction, or mixed number).
Named Argument: reduced When true, requires any fractional answer to be fully reduced.
assert_near(expected, given, options, feedback)
Checks numerically for algebraic equivalence of expressions, equations or lists.
assert_same_list(expected_list, given_list, compare_expression)
Checks that two lists have the same items in the same order and use the same delimiters. compare_expression uses the keywords index, item1 and item2 to determine how to compare the lists. It defaults to is_equal(item1, item2). Automatically adds feedback to the input when the student uses the wrong delimiters.
assert_interval_near(expected, given, options, feedback)
Checks numerically for algebraic equivalence of intervals or unions of intervals.
assert_derivative(expected, s, x, feedback)
Checks that ds/dx = expected. Defaults to checking symbolically, but if the named argument tolerance is set, it will check numerically.
assert_coterminal_angle(expected, given, feedback)
Checks that the student answer is coterminal to the expected angle and uses the correct unit (radians or degrees).
assert_congruent(expected, given, feedback)
Checks if the given expression is a geometric figure congruent to the expected figure.
expected The correct geometric figure or list of figures
given The student's answer
Named Argument: additional_points Optional list of additional points. For lines and rays, these are other collinear points along the correct line or ray. For major arcs, these are other points along the arc.
Named Argument: allow_vertex_only Allow angle(B) in the input to match angle(ABC) in the expected figures.
assert_custom(condition, feedback)
Custom check. If condition is true, marks the input as correct and increments the score. Otherwise marks it as incorrect and shows feedback.
Named Argument: input The input box that feedback should be shown on
is_valid(e)
Returns true if e is a valid expression.
is_error(value)
Returns true if the value is an error, such as compute(1/0) or exclude(1, 1).
is_equal(a, b)
Returns true if two expressions are the same. This does not evaluate anything, so 1 + 1 ≠ 2 and sin(0) ≠ 0.
is_equivalent(a, b)
Returns true if two expressions or lists are algebraically equivalent. 1 + 2 is equivalent to 3, and x+y is equivalent to y+x. Currently this is implemented by checking that (a - b) = 0.
is_near(a, b, options)
Returns true if abs(a - b) <= tolerance. This test uses numerical approximations to determine if two expressions are approximately equal. In the simplest case it compares to numbers (or numerical expressions): is_near(A, B, tolerance=0.1) returns true if |A-B| <= 0.1. When A and B are expressions that contain variables, it will run 20 tests with different values for each variable, and return true if each test has a difference within the tolerance. The default tolerance is 0 and the default range is [-10, 10]. You can override the range for the variable V by passing an argument V_range=range. For example, is_near(A, B, x_range=[-20,20],y_range=list(0,16]). Because the selection of values to check is arbitrary, it may miss values that are critical for your expression. For example, is_near(test(x<3, 5, 1), test(x<=3, 5, 1)) may return true. You can ensure that specific values are tested for variable V by passing an argument V_range=values. For example, is_near(test(x<3, 5, 1), test(x<=3, 5, 1), x_values=[3]).
is_match(pattern, expression)
Pattern matching. For more details, see the Pattern Matching page.
pattern Pattern to match against
expression Expression to test.
Named Argument: commutative Whether to enable commutative matching for addition and multiplication
Named Argument: commutative_multiplication Whether to enable commutative matching for multiplication only
Named Argument: commutative_addition Whether to enable commutative matching for addition only
Named Argument: sets If true, ignore item order for curly and no-delimiter lists
Named Argument: exact_mode Whether to enable exact matching mode
Named Argument: implicit Whether to enable implicit matching missing terms
Named Argument: tolerance If set, allows numbers to match if they are near what is in the pattern.
is_interval_near(a, b, options)
is_interval_near(union(list(-infinity, -2], list[3,infinity)), union(list[3.09,infinity), list(-infinity, -2.09]), tolerance=0.1) returns True
is_coterminal_angle(expected, given)
Returns true if two angles are coterminal and in the same form (radians or degrees).
expected the correct answer
given the student answer
is_congruent(expected, given)
Returns true if the given expression is a geometric figure congruent to the expected figure.
expected The correct geometric figure or list of figures
given The student's answer
Named Argument: additional_points Optional list of additional points. For lines and rays, these are other collinear points along the correct line or ray. For major arcs, these are other points along the arc.
Named Argument: allow_vertex_only Allow angle(B) in the input to match angle(ABC) in the expected figures.
is_commutative_equal(a, b)
Returns true if two expressions are the same, allowing for commutative addition and multiplication. y + 2x = 2x + y, but y + x + x != 2x + y.
is_function(expression)
Returns true if expression is a function definition.
is_degrees(angle)
Returns true if an expression is in degrees (e.g. 12 deg).
is_mixed_number(value)
Returns true if the expression was entered using mixed number syntax
isprime(n)
Returns 1 if n is a prime number, 0 otherwise.
contains_function(name, e)
Returns true if e contains a call to the specified function.
contains_operator(operator, e)
Returns true if e contains the specified operator
operator Operator, as a string. Supports +, -, *, /, ^, +/-, =, <>, <, <=, >, >=, ~=, (, !, ^_ (repeating decimal), U (union), and unary operators u+, u-, and u+/-.
symbol_names(expression)
Returns a list of the symbols used in expression.
var_names(expression)
Returns a list of the variables used in expression.
left_hand_side(expression)
Returns the left-hand-side of an equation or inequality. If the expression has no comparisons, this will return the whole expression. For example, left_hand_side(3x + 2) => 3x + 2. If the expression has more than one comparison, this will return the left-most piece. For example: left_hand_side(3 < x < 5) => 3
right_hand_side(expression)
Returns the right-hand-side of an equation or inequality. If the expression has no comparisons, this will return $undefined. For example, right_hand_side(3x + 2) => $undefined. If the expression has more than one comparison, this will return everything right of the first comparison. For example: left_hand_side(3 < x < 5) => x < 5
numerator(x)
Returns the numerator of an expression.
denominator(x)
Returns the denominator of an expression. Returns 1 for expressions without explicit denominators.
decimal_place_count(value)
Returns the number of digits in the fractional part of a decimal number. Returns 0 for integers and -1 for other values.
‡test(a, b, c, d, ...)
Conditional evaluation. If a is true, returns b, else if c is true returns d, etc. If the number of arguments is odd and all conditions are false, returns the last argument.
indicate_correct(input)
Set an input to display as correct. Does not change the feedback or score.
indicate_incorrect(input)
Set an input to display as incorrect. Does not change the feedback or score.
adjust_score(points)
Adds 'points' to the score. This does not modify the maximum possible points, which must be set by using assertions, set_score, or adjust_max_score.
adjust_max_score(points)
Adds 'points' to the maximum possible score. This does not modify the student's earned score.
set_score(earned, max)
Sets the score to 'earned' out of 'max' possible points. This replaces any score set earlier in the code (e.g. by assertions).
feedback_variable_names(expected, given, feedback_string)
Adds feedback if the student answer uses different variables than the expected answer.
feedback_rounding(correct_answer, student_answer, tolerance, feedback_string)
Adds feedback to check for rounding errors if student_answer is close, but not equivalent to correct_answer. Close means abs(correct_answer-student_answer) <= tolerance. Does not affect the score.
feedback_sign(expected, given, feedback_string)
Gives feedback if expected and given have the same absolute value, but opposite sign
feedback_list_form(expected, given, feedback_string)
Gives custom feedback if given does match the length and form of expected
feedback_geometry(input, [feedback_string])
Adds feedback if the student input is not geometric or contains invalid geometric objects.
feedback_degrees(expected, given, [feedback_string])
Gives default feedback if given contains a degree term but not as expected
feedback_interval(student_answer, feedback_string)
Adds feedback to check for errors in interval syntax from student_answer. For example, if their input has too many elements to be a valid interval. Does not affect the score.
feedback_function_expected(expression, feedback_string)
Gives feedback if expression is not a function definition.
set_feedback(feedback)
Set the feedback for a question
set_feedback(input, feedback)
Set the feedback for an input
add_feedback(feedback)
Add to the feedback for a question
add_feedback(input, feedback)
Add to the feedback for an input
clear_feedback(input)
Clear the input feedback
feedback_string(name)
Returns the html for a named feedback.