Symbolic differentiation vs computational graph in R

In R, both symbolic differentiation vs computational graph are implemented. Suppose we want to calculate the gradient of function f(x, y)=sin(x + y2). First, let’s look at symbolic differentiation: Next is the code for computational graph: We can see that the results are the same.

Calculate derivatives using symbolic differentiation in R

In base R, there is a function “deriv” from stats library to compute derivatives of simple expressions, symbolically and algorithmically. Here I use another function “Deriv” from Deriv library. To calculate both gradient and hessian matrix of a two-variable function: Then evaluate the value at point (2, 0) : To calculate the directional derivative ofContinue reading “Calculate derivatives using symbolic differentiation in R”

Create your own website, free on WordPress.com.Create your own website.
Start free