!!! note Below, expressions marked with a * may require our AsciiMath renderer definitions to display properly in edX.
By default, all of the following functions are made available to students in FormulaGrader
problems.
sin(x)
Sinecos(x)
Cosinetan(x)
Tangentsec(x)
Secantcsc(x)
Cosecantcot(x)
Cotangentsqrt(x)
Square Rootlog10(x)
Log (base 10)*log2(x)
Log (base 2)*ln(x)
Natural logarithmexp(x)
Exponentialarccos(x)
Inverse Cosinearcsin(x)
Inverse Sinearctan(x)
Inverse Tangentarctan2(x, y)
Four-quadrant Inverse Tangent*arcsec(x)
Inverse Secant*arccsc(x)
Inverse Cosecant*arccot(x)
Inverse Cotangent*abs(x)
Absolute value (real) or modulus (complex)factorial(x)
andfact(x)
Factorial*- domain: all complex numbers except negative integers. Large outputs may raise
OverflowError
s.
- domain: all complex numbers except negative integers. Large outputs may raise
sinh(x)
Hyperbolic Sinecosh(x)
Hyperbolic Cosinetanh(x)
Hyperbolic Tangentsech(x)
Hyperbolic Secantcsch(x)
Hyperbolic Cosecantcoth(x)
Hyperbolic Cotangentarcsinh(x)
Inverse Hyperbolic Sine*arccosh(x)
Inverse Hyperbolic Cosine*arctanh(x)
Inverse Hyperbolic Tangent*arcsech(x)
Inverse Hyperbolic Secant*arccsch(x)
Inverse Hyperbolic Cosecant*arccoth(x)
Inverse Hyperbolic Cotangent*floor(x)
Floor function (applies only to real numbers)ceil(x)
Ceiling function (applies only to real numbers)min(x, y, z, ...)
Minimum of the arguments (applies only to real numbers, 2 or more arguments)max(x, y, z, ...)
Maximum of the arguments (applies only to real numbers, 2 or more arguments)re(x)
Real part of a complex expression*im(x)
Imaginary part of a complex expression*conj(x)
Complex conjugate of a complex expression*kronecker(x, y)
Kronecker delta* (Note that we highly recommend integer sampling over a short range (eg, 1 to 4) when Kronecker deltas appear in an answer, and using many samples (eg, 30) so that most permutations appear in the sampling.)
In MatrixGrader
problems, all FormulaGrader
functions are available by default, as are the following extra functions:
abs(x)
: absolute value of a scalar or magnitude of a vectoradj(x)
: Hermitian adjoint, same asctrans(x)
*cross(x, y)
: cross product, inputs must be 3-component vectors*ctrans(x)
: conjugate transpose, same asadj(x)
*det(x)
: determinant, input must be square matrixnorm(x)
: Frobenius norm, works for scalars, vectors, and matricestrans(x)
: transpose*trace(x)
: trace
Available in FormulaGrader
, NumericalGrader
, and MatrixGrader
by default:
i
: imaginary unit (same asj
)j
: imaginary unit (same asi
)e
: approximately 2.718281828pi
: approximately 3.141592654
We provide a few collections of constants that can be imported for convenience and reuse. For example, pauli
is a dictionary with keys sigma_x
, sigma_y
, and sigma_z
that are MathArray
representations of the 2x2 Pauli matrices.
The collections of available mathematical constants are:
pauli
: MathArray representations of the 2x2 Pauli matrices,sigma_x
,sigma_y
, andsigma_z
cartesian_xyz
: MathArray representations of the three-dimensional Cartesian unit vectors, namedhatx
,haty
,hatz
cartesian_ijk
: MathArray representations of the three-dimensional Cartesian unit vectors, namedhati
,hatj
,hatk
Each collection is a dictionary that can be provided as a value of user_constants
:
>>> from mitxgraders import *
>>> grader = MatrixGrader(
... answers='sigma_x + sigma_z',
... user_constants=pauli
... )