Run the following code to see how to compute derivatives with Sage:
var('x, y') f(x, y) = 3 * x^4 * y^3 + 9 * y * x^2 - 4 * x + 8 * y print("f(x,y):") f.show() dfdx(x, y) = diff(f, x) print("df/dx:") dfdx.show() dfdy(x, y) = diff(f, y) print("df/dy:") dfdy.show() print("Second derivative:") d2fdx2(x, y) = derivative(f, x, 2) # Synonym for diff d2fdx2.show() # Trigonometric functions g(x) = sqrt(x^3 + csc(x)) print("g(x):") g.show() dgdx(x) = g.diff(x) print("dg/dx:") dgdx.show() # Implicit differentiation # The next line tells Sage that y is a function of x y(x) = function('y', x) expr = 5 * y^2 + sin(y) == x^2 print("Expression:") expr.show() # take the derivative and solve for dy/dx dydx = solve(diff(expr), diff(y)) print("dy/dx:") dydx[0].show()
The results are shown in the following screenshot: