Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create Python function DDeriv (f,x,y,h,v) which, for a given function f and given point (x,y), step size h>0 and vector v, computes directional derivative Dfevi(x,y)
Create Python function DDeriv (f,x,y,h,v) which, for a given function f and given point (x,y), step size h>0 and vector v, computes directional derivative Dfevi(x,y) of f at (x,y) in the direction v. Note that we need to normalize v to compute this directional derivate by Deif(x,y)=fx(x,y),fy(x,y)vv where the partial derivatives are computed numerically by central difference formulae: fx(x,y)2hf(x+h,y)f(xh,y)fy(x,y)2hf(x,y+h)f(x,yh) You may want to use method for dot product, and linalg.norm() for the norm of a vector. That is, if is imported with alias (as it is at the beginning of this notebook), then - use for dot product of vectors and (with and being tuples or list objects) - use for the norm of the vector (with being a tuple or a list object) \# your code here raise NotImplementedError "" "Check whether your answer is correct for some functions and at some points and in some directions""" assert np. abs(DDeriv (f=1 lambda x,y:x2+y2+2,x=0.4,y=0.2,h=1e5,v=(0.6,0.8))0.16)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started