Gradients

Description

The gradient of a function $g(x, y)$ is defined as

(1)
\begin{align} \nabla g(x, y) = \left( \frac{\partial g}{\partial x}, \frac{\partial g}{\partial y} \right). \end{align}

The sage cell below calculates the gradient of the function $g(x,y)=xy + \sin(x^2)+e^{-x}$.

Sage Cell

Code

x,y=var('x', 'y')
g(x,y)=x*y + sin(x^2) + e^(-x)
g.gradient()

Options

Option

You can also use g.derivative() or diff(g) to calculate the gradient.

Code

x,y = var('x', 'y')
g(x,y) = x*y + sin(x^2) + e^(-x)
g.derivative()

Tags

Primary Tags: Calculus - multivariable

Secondary Tags: Differentiation of multivariable functions: Directional derivatives and the gradient, Vector calculus: Derivatives

Related Cells

Attribute

Permalink: http://www.gregorybard.com/Sage.html

Author: Gregory V. Bard, Sage for Undergraduates.

Date: 02 Oct 2018 05:57

Submitted by: James A Phillips

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License