Question

For the function, f (x) = X2-4X + 2XY + 2Y2 + 2Y +14 Plot the...

For the function, f (x) = X2-4X + 2XY + 2Y2 + 2Y +14 Plot the surface function for X over [5 6]. and Y over [-4. -2],. Draw the contour plot for X over [0 10]. and Y over [-4. -2] and values for the contours of V=[1 1.25 1.5 2 2.5 3]; Write an m-file to find the minimum of the function using the gradient descent method. Use a starting value of [4. -4].

Homework Answers

Answer #1

x = linspace(5,6,100);
y = linspace(-4,-2,100);
[X,Y] = meshgrid(x,y);
f = X.^2 - 4*X + 2*X.*Y + 2*Y.^2 + 2*Y + 14;
figure, surf(X,Y,f), title('Surface Plot')
xlabel('X'), ylabel('Y'), zlabel('f(x)')

x = linspace(0,10,100);
y = linspace(-4,-2,100);
[X,Y] = meshgrid(x,y);
f = X.^2 - 4*X + 2*X.*Y + 2*Y.^2 + 2*Y + 14;
v = [1.0 1.25 1.5 2 2.5 3];
figure, contour(X,Y,f,v,'ShowText','on')
xlabel('X'), ylabel('Y'), title('Contour Plot')

f = @(x) x(1)^2 - 4*x(1) + 2*x(1)*x(2) + 2*x(2)^2 + 2*x(2) + 14; % x(1) => X, x(2) => Y
x0 = [4 -4];
x = fminunc(f, x0); % gradient search
fprintf('Solution: X = %.4f, Y = %.4f\n', x(1), x(2))
fprintf('Minimum value of f(x) = %.4f\n', f(x))

Output:

Solution: X = 5.0000, Y = -3.0000
Minimum value of f(x) = 1.0000

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
The local maximum value of the function f(x,y) = x2 + 2y2 − 2xy − 4y...
The local maximum value of the function f(x,y) = x2 + 2y2 − 2xy − 4y + 3 is (A) −6 (B) 4 (C) −1 (D) 1 (E) 3 (F) none of (A) - (E)
Perform two iterations of the gradient search method on f(x,y)= x2+4xy+2y2+2x+2y. Use (0,0) as a starting...
Perform two iterations of the gradient search method on f(x,y)= x2+4xy+2y2+2x+2y. Use (0,0) as a starting point. You must do this by hand. Please find the optimal λ* by taking the derivative and setting it equal to 0.
Find the absolute maximum value and absolute minimum value of f(x,y) = x2 +2y2−2x−4y+1 on the...
Find the absolute maximum value and absolute minimum value of f(x,y) = x2 +2y2−2x−4y+1 on the region D = {(x,y) ∈ R2 : 0 ≤ x ≤ 2,|y−1.5|≤ 1.5}
Consider the surface defined by z = f(x,y) = x+y^2+1. a)Sketch axes that cover the region...
Consider the surface defined by z = f(x,y) = x+y^2+1. a)Sketch axes that cover the region -2<=x<=2 and -2<=y<=2.On the axes , draw and clearly label the contours for the eights z=0 ,z=1,and z=2. b)evaluate the gradients of f(x,y) at the point (x,y) = (0.-1), and draw the gradient vector on the contour diagrqam . c)compute the directional derivative at(x,y) = (0,-1) in the direction V =<2,1>.
f(x, y) = x2 + y2 + 2xy + 6. 1. Find all the local extremas....
f(x, y) = x2 + y2 + 2xy + 6. 1. Find all the local extremas. 2. Does the function f has an absolute max or min on R2 ? 3. Draw E = {(x, y) ∈ R2; x >=0; y >=0; x + y<=1}. 4. Explain why f has an absolute max and min on E and find them.
Determine the absolute minimum and maximum values of the function f(x, y) = 2x^2 −2xy +y^2...
Determine the absolute minimum and maximum values of the function f(x, y) = 2x^2 −2xy +y^2 −2y + 7 on the closed triangular region with vertices (0, 0), (3, 0), and (0, 3).
A quadratic function is given: f(x)=x2 + 4x − 2 a) express f in standard form...
A quadratic function is given: f(x)=x2 + 4x − 2 a) express f in standard form (I already got that and it was (x+2)^2-6 b) sketch a graph of f c) Find the maximum or minimum value of f. Is this value a maximum or minimum value?
In Problems 14–21, does the function have a global maximum? A global minimum? 14. f(x, y)...
In Problems 14–21, does the function have a global maximum? A global minimum? 14. f(x, y) = x2 − 2y2
Consider the function f(x, y) = sin(2x − 2y) (a) Solve and find the gradient of...
Consider the function f(x, y) = sin(2x − 2y) (a) Solve and find the gradient of the function. (b) Find the directional derivative of the function at the point P(π/2,π/6) in the direction of the vector v = <sqrt(3), −1>   (c) Compute the unit vector in the direction of the steepest ascent at A (π/2,π/2)
Find the maximum and minimum values of f(x,y,z)=2x-2y-z on the closed and bounded set 4x^2+2y^2+z^2 ≤...
Find the maximum and minimum values of f(x,y,z)=2x-2y-z on the closed and bounded set 4x^2+2y^2+z^2 ≤ 1
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT