Please use matlab for the following problem
a.Matlab Code
[X,Y] = meshgrid(5:0.1:6,-4:.1:-2);
Z = X.^2-4*X+2*X.*Y+2*Y.^2+2*Y+14;
surf(X,Y,Z)
Output
b. Matlab Code
x = linspace(0,10);
y = linspace(-4,-2);
[X,Y] = meshgrid(x,y);
Z = X.^2-4*X+2*X.*Y+2*Y.^2+2*Y+14;
v = [1 1.25 1.5 2 2.5 3];
Output
(c)Gradient Descent Method
Matlab Code
function file steep.m code
function [f]=steep(x)
f=(x(1))^2-4*x(1)+2*x(1)*x(2)+2*(x(2))^2+2*(x(2))+14;
end
Steepest descent main m file
clc
clear
n=input('input n');
y=input('y');
tic
B=zeros(n,n);
x=sym('x', [n 1],'real');
f=steep(x);
J=jacobian(f,x);
fun_ev=1;
NORM=1;
k=0;
%H=eye(n);
time=0;
while(1~=2)
L1=vpa(subs(J,x,y),7);
NORM=vpa(norm(L1),7);
if(NORM<10^-6)
display('flag NORM');
break;
end
if(time>3000)
display('flag TIME');
break;
end
% p=-H*vpa((subs(J,x,y))',7);
p=-vpa((subs(J,x,y))',7);
alpha=1;
beta=0.5; %sigma in given problem
c1=0.1;%s in given problem
%c2=0.9;
fun_ev=fun_ev+1;
while(vpa(subs(f,x,y+alpha*p),7)>
vpa(subs(f,x,y),7)+c1*alpha*p'*vpa(subs(J,x,y)',7))
alpha=beta*alpha;
end
z=vpa(y+alpha*p,7);
fun_ev=fun_ev+1;
k=k+1;
y=z;
time=toc;
end
k
toc
NORM
y
f1=steep(y)
fun_ev
Output
input n2
y[4;-4]
flag NORM
k =
38
Elapsed time is 16.544480 seconds.
NORM =
0.0000009536743
y =
4.999999 (Minimizer)
-3.0
f1 =
1.000000000000454747350886464119 (Minimum Value)
fun_ev =
77
I. For the function. /(x) -X-4X+2XY+2Y+2Y+14 a. Plot the surface function for X over [5 6]. and Y...
1). For the function, f(x) X-4X+2XY+2Y2+2Y+14 a. Plot the surface function for X over [5 61, and Y over [-4,-2]," b. Draw the contour plot for X over [0 10], and Y over [-4,-2] and values for the contours 1.25 1.5 2 25 3 of V c. Write an m-file to find the minimum of the function using the gradient descent method. Use a starting value of [4,-4]. 1). For the function, f(x) X-4X+2XY+2Y2+2Y+14 a. Plot the surface function for...
Create a surface plot and a contour plot of the function z=(x-2)^2+2xy+y^2. Using the matlab
6. Plot the 3D surface and contour levels of the following function: z(x, y)cos(2y-x) sin(2x) such that-π x π and-r y < π [10 marks] 7. Create a 5 x 5 random matrix M6 with elements ranging from 10 to 33. Using indexing, define the following arrays: An array containing all elements of M6 that are greater than 3 and smaller 6 marks] An array containing all elements of M6 that are negative or between 29 and 33. 6 marks...
(d) The line integral [(x+y?)dx + (x2 + 2xy)dy, where the positively oriented curve C is the boundary of the region in the first quadrant determined by the graphs of x=0, y=x2 and y=1, can be converted to A 2xdydx 0 0 BJ 2 xdxdy 0 0 С -2x)dyda 00 D none of the above (e) Consider finding the maximum and minimum values of the function f(x, y) = x + y2 - 4x + 4y subject to the constraint...
(1 point) Find the linearization of the function f(x,y) = 72 - 4x² – 2y at the point (3, 4). L(x,y) Use the linear approximation to estimate the value of f(2.9, 4.1) f(2.9, 4.1)
5. Suppose that a firm's total profit function is P(x,y) = 2xy + 2y+12-(2x2 +y2), where x is amount of production and sales of the first product and y - of the second produc 1) Find all first and second order partial derivatives. 2) Find values of x and y that maximize the profit. Find the maximum profit. 6. Ifx thousand euros is spend on labor and y thousand euros is spend on equipment, the outpu certain factory will be...
-/5 POINTS Compute the surface integral of the function f(x, y, z) = 3xy over the portion of the plane 4x + 3y +z - 12 that lies in the first octant. Submit Answer
how to do all the questions? 10 6 2.4) 4 -2 -8 -10 -10 -8 -2 The contour plot above shows the level curves of some surface given by the function z-f(x, y). At (-8,2) the green vectors e and w are tangential to the contour there, and the blue vectors are perpendicular to the green ones. Moreover, at any point (in the frame above), we know that oflàx > 0 Which of the following vectors could represent Vf(-8, 2)...
#3 please!! 2. Given the function f(x, y)-x2 +y -2xy -6x - 2y 5, find the following: (a) Find the critical point(s) of the function. For full credit, show all the algebra to find these and give your answer as ordered pairs. (b) Find the second order partial derivatives and use these to find the determinant of each critical point. Then classify each critical point as a saddle point, relative minimum, or relative maximum point. 3. A wine dealer sells...
1. (25 points) The figure below shows the contour plot of f(x,y)-3 -1 - 2y+y. (Credit for the figure is due to UMich instructors.) 6.00U 6.000 1.5 1.0 0.5 0.0 0.5 1.0 1.5 6.000 2.0-1.5-1.0-0.5 0.0 0.5 1.0 1.5 (a) Find all critical points of f. There should be six. Mark them on the contour plot. (Think, but don't write, about how to guess the critical points from the contour plot.) (b) Find f-,) v(,),and fp()-fy(, y) (c) Try to...