Canvas Formula Quiz Question Helper Functions

This document lists the helper functions that can be used to build formulas for formula quiz questions. 



Canvas requires users to manually input formulas when creating formula quiz questions with variables. The Formula Definition section of the formula quiz question builder includes a text field where users must define the quiz question formula (see image below).

View Formula DefinitionView Formula Definition

 

For more information about using the Math Editor in the Rich Content Editor to build formula quiz questions, view additional resource documents: How do I use the Math Editor in the Rich Content Editor?, Canvas Equation Editor Tips: Math Expressions Using LaTeX and Canvas Equation Editor Tips: Chemistry Using LaTeX.  

Helper Functions 

Use the helper functions listed below to build formulas in the Formula Definition section of the Formula question quiz question creator. 


Notes: 

  • All functions accept only numeric parameters. 
  • All trigonometric function calculations are performed in radians. To convert to or from degrees, use the deg_to_rad( ) or rad_to_deg( ) functions.
  • The Formula Definition text field does not designate definable variables with square brackets. 
  • Variables must start with a letter and may be followed by any combination of letters and numbers. Keep in mind that variable names are case sensitive and characters other than letters and numbers are not recognized. 
  • In the Formula Definition text field, Canvas translates the entry of the letter “e” as the constant e. 
  • Helper functions can be nested. For an example of nested helper functions, see the entry for At in the table below. 
  • Several functions operate on a list of numbers. Unless otherwise noted, the list parameter is defined with a comma-separated list of values or with a nested reverse( ) or sort( ) function. For example, use either median (x1, x2, x3) or median(reverse(x3,x2,x1)). 
  • To negate an expression in the Formula Definition field, multiply the function by -1. For example, type -1*sqrt(5x).

Name

Helper Function

Notes

Absolute Value

abs(x)

Returns the absolute value of a given value

Arccosine

acos(x)

Returns the inverse cosine of a real number x as a radian measure

Arcsine

asin(x)

Returns the inverse sine of a real number x as a radian measure

At

at(list, index)

Returns the indexed value in the given list

Create the list portion of this function by nesting the sort( ) or reverse( ) functions within the at( ) function. For example: at(reverse(x1, x2, x3), n-1) 

The first value in the list is at index 0

Arctangent

atan(x)

Returns the inverse tangent of a real number x as a radian measure

This function does not support two parameters

Ceiling

ceil(x)

Returns the smallest integer greater than or equal to the given value

Combination

comb(n, k)

Returns the number of combinations when k is chosen from a group of n

Cosine

cos(radians)

Returns the cosine of the given value

Cosecant

cosec(radians)

Returns the cosecant of the given value

Cotangent

cotan(radians)

Returns the cotangent of the given value

Count

count(list)

Returns the number of items in the list

Degrees to Radians

deg_to_rad(degrees)

Converts an angle x from degrees into radians by multiplying by 𝜋/180

Euler’s Number, e 

Returns the value for e

Though parentheses may be used with this function, Canvas translates the entry of the letter “e” as the constant e

Factorial

fact(n)

Returns the factorial of the given integer

If n is not an integer, then only the numbers before the decimal point are used. 

If n input is negative, then 1 is returned 

First

first(list)

Returns the first value in the list

Floor

floor(x)

Returns the smallest integer less than or equal to the given value

If

if(bool, success, fail)

If the first expression evaluates to a non-zero value, then it returns the second value, otherwise it returns the third value

Last

last(list) 

Returns the last value in the list

Length

length(list)

Returns the number of arguments in the given list

Logarithm (natural) 

ln(x)

Returns the natural log of the given value

Logarithm (common)

log(x, [base])

Returns the log of the given value with an optional base

Maximum

max(list)

Returns the highest value in the list

Mean

mean(list)

Returns the arithmetic mean or average of the values in the list

Median

median(list)

Returns the median for the list of values

Minimum

min(list)

Returns the lowest value in the list

Permutation

perm(n, k)

Returns the permutation result for the given values

Pi, 𝛑

pi( )

Returns the computed value of pi

Radians to Degrees

rad_to_deg(radians)

Converts an angle x from radians to degrees by multiplying by 180/𝜋

Random

rand(x)

Returns a random number between zero and the range specified, or one if no number is given

Range

range(list)

Returns the range for the list of values

Reverse

reverse(list)

Reverses the order of the list of values

Round

round(x)

Returns the given value rounded to the nearest whole number

Secant

sec(radians)

Returns the secant of the given value

Sine

sin(radians)

Returns the sine of the given value

Sort

sort(list)

Returns the list of values, sorted from lowest to highest

Square Root

sqrt(x)

Returns the square root of the given real number x

To obtain the negative square root, use -1*sqrt(x)

Sum

sum(list)

Returns the sum of the list of values

Tangent

tan(radians)

Returns the tangent of the given value

 


Last update: 2021-01-16

This resource can also be accessed from the following Canvas Guides:

Labels (1)