Question

find maximum value with steepest ascent method of f(x,y)=5+2xy+2y-x^2-2y^2 by: a)program code(any but matlab is preferred)...

find maximum value with steepest ascent method of
f(x,y)=5+2xy+2y-x^2-2y^2 by:
a)program code(any but matlab is preferred)
b)without program code
Do 3times of iteration with initial guess is (x,y)=(0.25,0.25)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hi,

Here is the required code:-

% function definition

func=@(x,y) 5+2.*x.*y +2.*y -x.^2 -2.*y.^2;

% Initial guess of x0 and y0

x0=0.25;
y0=0.25;

dx=0.001;
dy=0.001;

% initial alpha
alpha = 0.5;

%tolerance
tol =1e-6;
g = [inf;inf];


while norm(g) > tol

% compute gradient
  
f1=func(x0-dx/2,y0);
f2=func(x0+dx/2,y0);
gx=(f2-f1)/dx;
  
f1=func(x0,y0-dy/2);
f2=func(x0,y0+dy/2);
gy=(f2-f1)/dy;
g=[gx;gy];
% updating the x0 and y0 values with alpha
x0=x0+alpha*gx;
y0=y0+alpha*gy;
    
end

% displaying the value
[x0,y0]

output:-

b) Theoritical calculation:-

Add a comment
Know the answer?
Add Answer to:
find maximum value with steepest ascent method of f(x,y)=5+2xy+2y-x^2-2y^2 by: a)program code(any but matlab is preferred)...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT