Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Need help with a matlab problem. THX! The function is somewhat whimsically known as Rosenbrock's banana function. It is often used as a benchmarking test
Need help with a matlab problem. THX!
The function is somewhat whimsically known as Rosenbrock's banana function. It is often used as a benchmarking test for optimization algorithms because it is easy to find the minimum analytically but often very tricky numerically. In this problem we will explore a method called gradient descent to find this minimum. Throughout the problem, we will use the values a = 1 and b= 10. You can plot this function using the following code y -10:0.2:10; (X, Y] meshgrid(x, y); surf(X, Y, z) (a) Write a Matlab function that computes f using only one input. (That is, your function should only use one variable.) Use this function to calculate f(-1,8) and save the result in A1.dat (b) Use fminsearch to find the minimum of f and save it as a 2 1 vector [XI; in the file A2.dat. Use an initial guess of [-l; 8 Things to think about: Can you confirm the minimum of f analytically? This should be easy.) Try timing fminsearch. How long does it take to find this minimum? c) Find a formula for the gradient ( T2). Recall from calculus that the gradient is defined as the 2 1 vector T1, T2 T1, T2 1, 2) Calculate f(-1.8) and save the resulting 2 1 vector in A3. dat. The function is somewhat whimsically known as Rosenbrock's banana function. It is often used as a benchmarking test for optimization algorithms because it is easy to find the minimum analytically but often very tricky numerically. In this problem we will explore a method called gradient descent to find this minimum. Throughout the problem, we will use the values a = 1 and b= 10. You can plot this function using the following code y -10:0.2:10; (X, Y] meshgrid(x, y); surf(X, Y, z) (a) Write a Matlab function that computes f using only one input. (That is, your function should only use one variable.) Use this function to calculate f(-1,8) and save the result in A1.dat (b) Use fminsearch to find the minimum of f and save it as a 2 1 vector [XI; in the file A2.dat. Use an initial guess of [-l; 8 Things to think about: Can you confirm the minimum of f analytically? This should be easy.) Try timing fminsearch. How long does it take to find this minimum? c) Find a formula for the gradient ( T2). Recall from calculus that the gradient is defined as the 2 1 vector T1, T2 T1, T2 1, 2) Calculate f(-1.8) and save the resulting 2 1 vector in A3. datStep 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