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" , EndFractiondda followed by the expression, where a is the variable to differentiate with respect to:
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 1ddaa2+1equals 7=7
StartFraction, "d" Over "d" "a" , EndFraction left parenthesis, "a" squared plus 1 , right parenthesisddaa2+1equals 6=6
The expression must come after the fraction. Writing it in the numerator, as in StartFraction, "d" "b" Over "d" "a" , EndFractiondbda, 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"ddab instead. Prime notation such as "f" prime ( "a" )f′(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 , EndFractiond2da2. Nesting one derivative inside another means the same thing. With a=2:
StartFraction, "d" squared Over "d" "a" squared , EndFraction "a" cubedd2da2a3equals 12=12
StartFraction, "d" Over "d" "a" , EndFraction left parenthesis, StartFraction, "d" Over "d" "a" , EndFraction "a" cubed , right parenthesisddaddaa3equals 12=12
StartFraction, "d" to the 4th power Over "d" "a" to the 4th power , EndFraction "a" cubedd4da4a3equals 0=0
The order has to be a literal whole number, and the two orders have to agree: StartFraction, "d" squared Over "d" "a" cubed , EndFractiond2da3 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" cubedd2dadba2b3equals 24=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 2a=2
"b" equals "a" squaredb=a2
"c" equals sin left parenthesis, "b" , right parenthesisc=sinb
StartFraction, "d" Over "d" "a" , EndFraction "c"ddacequals negative 2.6 1 4 5 7=−2.61457
The same goes for your own functions. With a=3:
"f" left parenthesis, "u" , right parenthesis equals "u" squaredfu=u2
StartFraction, "d" Over "d" "a" , EndFraction "f" left parenthesis, "a" , right parenthesisddafaequals 6=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θ=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 matrixddθcosθsinθequals Start 2 by 1 matrix, Row 1: 0; Row 2: 1, End matrix=01
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.
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 matrixv=12:
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 2a=2
StartFraction, "d" Over "d" "a" , EndFraction left bracket, "a" , "a" squared , right bracketddaa,a2equals left bracket, 1 , 4 , right bracket=1,4
left bracket, StartFraction, "d" Over "d" "a" , EndFraction "a" , StartFraction, "d" Over "d" "a" , EndFraction "a" squared , right bracketddaa,ddaa2equals left bracket, 1 , 4 , right bracket=1,4
Likewise, these two situations are equivalent:
"A" equals left bracket, 2 , 3 , right bracketA=2,3
StartFraction, "d" Over "d" "A" , EndFraction left parenthesis, "A" left bracket, 0 , right bracket positive "A" left bracket, 1 , right bracket squared , right parenthesisddAA0+A12equals left bracket, 1 , 6 , right bracket=1,6
"a" equals 2a=2
"b" equals 3b=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 bracketddaa+b2,ddba+b2equals left bracket, 1 , 6 , right bracket=1,6
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 bracketA=1,2,3
"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 bracketB=A0+A1,A22,sinA1equals left bracket, 3 , 9 , 0.9 0 9 2 9 7 4 2 6 8 2 5 6 8 2 , right bracket=3,9,0.909297426825682
"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 bracketB=A0+A1,A22,sinA1equals left bracket, 3 , 9 , 0.9 0 9 2 9 7 4 2 6 8 2 5 6 8 2 , right bracket=3,9,0.909297426825682
StartFraction, "d" Over "d" "A" Subscript, 0 , Baseline , EndFraction "B"ddA0Bequals left bracket, 1 , 0 , 0 , right bracket=1,0,0
StartFraction, "d" Over "d" "A" Subscript, 1 , Baseline , EndFraction "B"ddA1Bequals left bracket, 1 , 0 , negative 0.4 1 6 1 4 6 8 3 6 5 4 7 1 4 2 , right bracket=1,0,−0.416146836547142
StartFraction, "d" Over "d" "A" Subscript, 2 , Baseline , EndFraction "B"ddA2Bequals left bracket, 0 , 6 , 0 , right bracket=0,6,0
What cannot be differentiated
Derivatives of the matrix exponential, and determinants of matrices larger than 4 by 4, and colors are currently not supported.
The matrix exponential
Colours.
Differentiating with respect to a loop counter: the variable of a sum, product, for or iterate is a count, not a value that varies.
A result with three or more dimensions, such as a matrix differentiated with respect to a vector, can be computed but not displayed. Use it in another box, for example multiplied by a vector, to bring it back down to a matrix.
Two cases give an undefined value (NaN) rather than an error, because the derivative genuinely does not exist there:
min and max exactly where their two arguments are equal.
The absolute value, real part, imaginary part or conjugate of a complex expression, differentiated with respect to a complex variable, wherever the value is not real. Differentiating these with respect to a real variable is fine.