Second-Order Derivatives and the Hessian
Learn what second-order derivatives are and how to calculate the Hessian of a function.
We'll cover the following...
As derivatives are functions, they have their own derivatives. The derivative of a derivative is called a second-order derivative. In the following code, we calculate the second-order derivative of .
from sympy import symbols, diffx = symbols('x')f = x**2df = diff(f, x) # first-order derivativeddf = diff(df, x) # second-order derivativeprint("First-order:", df)print("Second-order:", ddf)
Second-order derivatives in multiple dimensions
In cases with more than one variable, we can calculate the second-order derivative with respect to the same first variable or with respect to another variable. For example, we denote as the operation of taking the derivative of with respect to and then taking again the derivative with respect to . But we could take the second derivative with respect to another variable. We denote as when we first take the derivative with respect to and then with respect to ...