Directional Derivatives
Swipe um das Menü anzuzeigen
The directional derivative of a function describes how the function changes as you move from a point in a specific direction. For a function f(x,y), the directional derivative at a point (x0,y0) in the direction of a unit vector u=(a,b) is given by:
Duf(x0,y0)=∇f(x0,y0)⋅u=fx(x0,y0)a+fy(x0,y0)bHere, ∇f(x0,y0) is the gradient vector at (x0,y0), fx and fy are the partial derivatives, and ⋅ denotes the dot product.
Example:
Suppose f(x,y)=x2+y2 and you want the directional derivative at (1,2) in the direction of vector v=(3,4). First, normalize v to get the unit vector u=(3/5,4/5). The gradient at (1,2) is (2x,2y)=(2,4). The directional derivative is:
Duf(1,2)=(2,4)⋅(3/5,4/5)=2∗(3/5)+4∗(4/5)=(6/5)+(16/5)=22/5This value tells you how fast the function increases if you move from (1,2) in the direction (3,4).
1234567891011121314151617181920212223242526import numpy as np def gradient(f, x, h=1e-6): n = len(x) grad = np.zeros(n) for i in range(n): x_forward = np.array(x) x_backward = np.array(x) x_forward[i] += h x_backward[i] -= h grad[i] = (f(*x_forward) - f(*x_backward)) / (2 * h) return grad def directional_derivative(f, x0, direction): direction = np.array(direction) unit_direction = direction / np.linalg.norm(direction) grad = gradient(f, x0) return np.dot(grad, unit_direction) # Example usage: # f(x, y) = x^2 + y^2 f = lambda x, y: x**2 + y**2 point = [1, 2] direction = [3, 4] result = directional_derivative(f, point, direction) print(f"Directional derivative at {point} in direction {direction}: {result:.2f}")
Danke für Ihr Feedback!
Fragen Sie AI
Fragen Sie AI
Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen
Directional Derivatives
The directional derivative of a function describes how the function changes as you move from a point in a specific direction. For a function f(x,y), the directional derivative at a point (x0,y0) in the direction of a unit vector u=(a,b) is given by:
Duf(x0,y0)=∇f(x0,y0)⋅u=fx(x0,y0)a+fy(x0,y0)bHere, ∇f(x0,y0) is the gradient vector at (x0,y0), fx and fy are the partial derivatives, and ⋅ denotes the dot product.
Example:
Suppose f(x,y)=x2+y2 and you want the directional derivative at (1,2) in the direction of vector v=(3,4). First, normalize v to get the unit vector u=(3/5,4/5). The gradient at (1,2) is (2x,2y)=(2,4). The directional derivative is:
Duf(1,2)=(2,4)⋅(3/5,4/5)=2∗(3/5)+4∗(4/5)=(6/5)+(16/5)=22/5This value tells you how fast the function increases if you move from (1,2) in the direction (3,4).
1234567891011121314151617181920212223242526import numpy as np def gradient(f, x, h=1e-6): n = len(x) grad = np.zeros(n) for i in range(n): x_forward = np.array(x) x_backward = np.array(x) x_forward[i] += h x_backward[i] -= h grad[i] = (f(*x_forward) - f(*x_backward)) / (2 * h) return grad def directional_derivative(f, x0, direction): direction = np.array(direction) unit_direction = direction / np.linalg.norm(direction) grad = gradient(f, x0) return np.dot(grad, unit_direction) # Example usage: # f(x, y) = x^2 + y^2 f = lambda x, y: x**2 + y**2 point = [1, 2] direction = [3, 4] result = directional_derivative(f, point, direction) print(f"Directional derivative at {point} in direction {direction}: {result:.2f}")
Danke für Ihr Feedback!