Derivatives

Eigenslate can differentiate expressions, including your own functions and definitions, with respect to numbers, vectors and arrays.

Writing a derivative

A derivative is written as StartFraction, "d" Over "d" "a" , EndFraction followed by the expression, where a is the variable to differentiate with respect to:

Recording of the calculator performing the steps described above

Like the Start sum from to , end sum, operator, a derivative applies only to the term immediately after it. A + ends it, so put parentheses around a sum to differentiate the whole thing. With a=3:

StartFraction, "d" Over "d" "a" , EndFraction "a" squared plus 1equals 7
StartFraction, "d" Over "d" "a" , EndFraction left parenthesis, "a" squared plus 1 , right parenthesisequals 6

The expression must come after the fraction. Writing it in the numerator, as in StartFraction, "d" "b" Over "d" "a" , EndFraction, is read as an ordinary fraction: d times b divided by d times a, which reports that d is not defined. Write StartFraction, "d" Over "d" "a" , EndFraction "b" instead. Prime notation such as "f" prime ( "a" ) and the partial symbol partial are not supported; use d for partial derivatives too.

Higher orders and several variables

For a higher derivative put the order on both the d and the da, as in StartFraction, "d" squared Over "d" "a" squared , EndFraction. Nesting one derivative inside another means the same thing. With a=2:

StartFraction, "d" squared Over "d" "a" squared , EndFraction "a" cubedequals 12
StartFraction, "d" Over "d" "a" , EndFraction left parenthesis, StartFraction, "d" Over "d" "a" , EndFraction "a" cubed , right parenthesisequals 12
StartFraction, "d" to the 4th power Over "d" "a" to the 4th power , EndFraction "a" cubedequals 0

The order has to be a literal whole number, and the two orders have to agree: StartFraction, "d" squared Over "d" "a" cubed , EndFraction is an error. At most five derivatives can be taken with respect to one variable at a time.

To differentiate with respect to several variables, list them all in the denominator, with the total order on top. This is the same as nesting one derivative inside the other. With a=1 and b=2:

StartFraction, "d" squared Over "d" "a" "d" "b" , EndFraction "a" squared "b" cubedequals 24

Differentiating through definitions

You can differentiate with respect to any variable defined in another box, and the derivative follows the whole chain of definitions between them, even when the expression does not mention the variable directly:

"a" equals 2
"b" equals "a" squared
"c" equals sin left parenthesis, "b" , right parenthesis
StartFraction, "d" Over "d" "a" , EndFraction "c"equals negative 2.6 1 4 5 7

The same goes for your own functions. With a=3:

"f" left parenthesis, "u" , right parenthesis equals "u" squared
StartFraction, "d" Over "d" "a" , EndFraction "f" left parenthesis, "a" , right parenthesisequals 6

Vectors, matrices and arrays

Differentiating a vector or matrix with respect to a number differentiates each entry. This gives the velocity of a point moving around a circle, with theta equals 0:

StartFraction, "d" Over "d" theta , EndFraction Start 2 by 1 matrix, Row 1: cos left parenthesis, theta , right parenthesis ; Row 2: sin left parenthesis, theta , right parenthesis , End matrixequals Start 2 by 1 matrix, Row 1: 0; Row 2: 1, End matrix

Differentiating a number with respect to a vector gives the gradient which is a vector with the same shape as the variable. Here f takes a vector and returns a number:

The gradient of f at S. Since S depends on x and y, the gradient is drawn as a vector field.
The gradient of f at S. Since S depends on x and y, the gradient is drawn as a vector field.

Each further derivative with respect to a vector adds a dimension, so the second derivative is the Hessian matrix. With "v" equals Start 2 by 1 matrix, Row 1: 1; Row 2: 2, End matrix:

StartFraction, "d" squared Over "d" "v" squared , EndFraction "f" left parenthesis, "v" , right parenthesisequals Start 2 by 2 matrix, Row 1: negative 0.7 6 5 1 4 7, negative 0.2 2 4 8 4 5; Row 2: negative 0.2 2 4 8 4 5, negative 0.7 6 5 1 4 7, End matrix

In the same way, differentiating a vector with respect to a vector gives the Jacobian matrix, with one row per entry of the result and one column per entry of the variable.

Differentiating an arrays gives the array containing the derivative of each element. Differentiating with respect to an array gives an array containing the derivative with respect to each element.

For example these two expressions are equivalent:

"a" equals 2
StartFraction, "d" Over "d" "a" , EndFraction left bracket, "a" , "a" squared , right bracketequals left bracket, 1 , 4 , right bracket
left bracket, StartFraction, "d" Over "d" "a" , EndFraction "a" , StartFraction, "d" Over "d" "a" , EndFraction "a" squared , right bracketequals left bracket, 1 , 4 , right bracket

Likewise, these two situations are equivalent:

"A" equals left bracket, 2 , 3 , right bracket
StartFraction, "d" Over "d" "A" , EndFraction left parenthesis, "A" left bracket, 0 , right bracket positive "A" left bracket, 1 , right bracket squared , right parenthesisequals left bracket, 1 , 6 , right bracket
"a" equals 2
"b" equals 3
left bracket, StartFraction, "d" Over "d" "a" , EndFraction left parenthesis, "a" plus "b" squared , right parenthesis , StartFraction, "d" Over "d" "b" , EndFraction left parenthesis, "a" plus "b" squared , right parenthesis , right bracketequals left bracket, 1 , 6 , right bracket

If you differentiate an array with respect to another array the result will be a 2D array where each row is the derivative of the array differentiated with respect to one of the element. Below is an example of this, along with an expanded version showing what it evaluates to.

"A" equals left bracket, 1 , 2 , 3 , right bracket
"B" equals left bracket, "A" left bracket, 0 , right bracket positive "A" left bracket, 1 , right bracket , "A" left bracket, 2 , right bracket squared , sin left parenthesis, "A" left bracket, 1 , right bracket , right parenthesis , right bracketequals left bracket, 3 , 9 , 0.9 0 9 2 9 7 4 2 6 8 2 5 6 8 2 , right bracket
StartFraction, "d" Over "d" "A" , EndFraction "B"equals Start 3 by 3 matrix, Row 1: 1, 0, 0; Row 2: 1, 0, negative 0.4 1 6 1 4 6 8 3 6 5 4 7 1 4 2; Row 3: 0, 6, 0, End matrix
"A" Subscript, 0 , Baseline equals 1
"A" Subscript, 1 , Baseline equals 2
"A" Subscript, 2 , Baseline equals 3
"B" equals left bracket, "A" Subscript, 0 , Baseline plus "A" Subscript, 1 , Baseline , "A" squared , sin left parenthesis, "A" Subscript, 1 , Baseline , right parenthesis , right bracketequals left bracket, 3 , 9 , 0.9 0 9 2 9 7 4 2 6 8 2 5 6 8 2 , right bracket
StartFraction, "d" Over "d" "A" Subscript, 0 , Baseline , EndFraction "B"equals left bracket, 1 , 0 , 0 , right bracket
StartFraction, "d" Over "d" "A" Subscript, 1 , Baseline , EndFraction "B"equals left bracket, 1 , 0 , negative 0.4 1 6 1 4 6 8 3 6 5 4 7 1 4 2 , right bracket
StartFraction, "d" Over "d" "A" Subscript, 2 , Baseline , EndFraction "B"equals left bracket, 0 , 6 , 0 , right bracket

What cannot be differentiated

Derivatives of the matrix exponential, and determinants of matrices larger than 4 by 4, and colors are currently not supported.

Two cases give an undefined value (NaN) rather than an error, because the derivative genuinely does not exist there: