The following list includes both WebAssign-specific and commonly used Perl functions and operators that are available when creating questions.
Numerical Operators
Operation |
Usage |
Notes |
---|---|---|
Test Numerical Equality |
|
Returns true (1) or false (0). Use |
Test Numerical Inequalities ( ≠ > < ≥ ≤ ) |
|
Returns true (1) or false (0). To compare strings, use |
Addition, Subtraction, Multiplication, Division |
|
|
Exponentiation |
|
|
Order of Operations |
|
Do not use |
Mathematic Functions
Operation |
Usage |
Notes |
---|---|---|
Absolute value |
|
|
Average (mean) |
|
Returns the mean of the values. Argument can be a list or an
array.
Example:
|
Greatest Common Divisor |
|
Argument can be a list or an array. |
Least Common Multiple |
|
Argument can be a list or an array. |
Maximum value |
|
Returns the greatest value. Argument can be a list or an array. |
Minimum value |
|
Returns the least value. Argument can be a list or an array. |
Pearson's correlation coefficient |
|
Returns the correlation between the values in two arrays. The arrays should be the same size. |
Sample standard deviation |
|
Returns the sample standard deviation of the values. Argument can be a
list or an array.
Example:
|
Slope of a bivariate linear regression |
|
Returns the slope of a linear regression using the values in two
arrays. The arrays should be the same size.
Example:
|
Square root |
|
n ≥ 0 |
Sum of array or list |
|
Returns the sum of the array or list. Argument can be a list or an
array.
Example:
|
Sum of products |
|
Returns the sum of the products of the deviations of the values of two arrays. The arrays should be the same size. |
Sum of squared deviations |
|
Returns the sum of squared deviations about the mean of the values.
Argument can be a list or an array.
Example:
|
Y intercept of a bivariate linear regression |
|
Returns the y intercept of a linear regression using the values in two
arrays. The arrays should be the same size.
Example:
|
Trigonometric Functions
Operation |
Usage |
Notes |
---|---|---|
Trigonometric Functions |
|
The value of n must be in radians. Non-canonical values of n might return approximate values. |
Inverse Trigononometric Functions |
|
Returns principal values in radians. |
Arctangent of y/x |
|
Returns radians from −π through π. |
pi (π) |
|
|
Degrees to radians |
|
Converts degrees to radians. |
Radians to degrees |
|
Converts radians to degrees. |
Get canonical angle in degrees |
|
Converts angle in degrees to value in range −180 to 180. |
Logarithmic Functions
Operation |
Usage |
Notes |
---|---|---|
Exponential function |
|
Euler's number raised to n. |
Natural Log |
|
n > 0 |
Log (base 10) |
|
n > 0 |
Combinatoric Functions
Operation |
Usage |
Notes |
---|---|---|
Combinations C(n,k) |
|
Returns the number of sets of k elements that can be picked from an n-element set. |
Permutations P(n,k) |
|
Returns the number of unique (ab is different from ba) sets of k elements that can be picked from an n-element set. |
Factorial (n!) |
|
n must be an integer from 1 through 100. |