Question

In: Advanced Math

On Matlab use BFGS Method to find the minimum of the following function: f(x) = x13...

On Matlab use BFGS Method to find the minimum of the following function: f(x) = x13 - 2x2x12 + x12 - x1using initial point (x0, y0) = (1, 2)T to start, and stop when f changes less than 0.0001

Solutions

Expert Solution

clear all;
clc;

H=eye(2,2);
syms a;
f=@(x,y) x^3-2*y*x^2+x^2-x;
g=@(x,y) deal(3*x^2-4*x*y+2*x-1,-2*x^2);
% f=@(x,y) 100*(y-x.^2).^2+(1-x).^2;
% g = @(x,y) deal( 400*x.^3-400*x*y+2*x-2,200*y-200*x.^2);
X=[1 2 ]';
N=7;
sum=X;
n=nargin(f);

for i=1:N
[u v]=g(X(1),X(2));
grad=[u v]';
d=-H*grad;
sum=sum+a*d;
z=f(sum(1),sum(2));
fd=matlabFunction(z);
derivative= matlabFunction(diff(fd(a)));

derivative1=matlabFunction(diff(derivative(a)));

my_val = 1;
n = 10;
for i=1:n

my_val=my_val-(derivative(my_val)/subs(sym(derivative1),{a},{my_val}));
end
alpha=my_val;

X=X+alpha*d;
sum=X;
deltax=alpha*d;
  
[n m]=g(X(1),X(2));
grad1=[n m]';
deltag=grad1-grad;
H=H+(deltax-H*deltag)*(deltax-H*deltag)'/(deltag'*(deltax-H*deltag));
%H=H+(deltax*deltax')/(deltax'*deltag)-(H*deltag)*(H*deltag)'/(deltag'*H*deltag);
% d=-H*grad1;

if (abs(n)< 1e-4&&abs(m)<1e-4)
break
end

end
% disp('The Solution is (X,Y):')

disp(vpa(X))

  


Related Solutions

Implement in MATLAB the Newton-Raphson method to find the roots of the following functions. (a) f(x)...
Implement in MATLAB the Newton-Raphson method to find the roots of the following functions. (a) f(x) = x 3 + 3x 2 – 5x + 2 (b) f(x) = x2 – exp(0.5x) Define these functions and their derivatives using the @ symbol. For example, the function of part (a) should be f=@(x)x^3 + 3*x.^2 - 5*x + 2, and its derivative should be f_prime=@(x)3*x.^2 + 6*x - 5. For each function, use three initial values for x (choose between -10...
Optimization Technique: Consider one-variable function f(x). Use Newton Method to find minimum/maximum and plot the graph....
Optimization Technique: Consider one-variable function f(x). Use Newton Method to find minimum/maximum and plot the graph. Use Matlab.
Use the secant Method to find a root for the function: f(x) = x^3 + 2x^2...
Use the secant Method to find a root for the function: f(x) = x^3 + 2x^2 + 10x -20, with x_0 = 2, and x_1 = 1.
7. Find the maximum and minimum of the function. f (x, y) = x^ 2 +...
7. Find the maximum and minimum of the function. f (x, y) = x^ 2 + y^ 2 − xy − 3x − 3y on the triangle D ={(x, y)| x ≥ 0, y ≥ 0, x + y ≤ 4}
Use Newton's method to find the absolute maximum value of the function f(x) = 3x cos(x),...
Use Newton's method to find the absolute maximum value of the function f(x) = 3x cos(x), 0 ≤ x ≤ π; correct to six decimal places.
Find the absolute maximum and the absolute minimum of the function f(x,y) = 6 - x²...
Find the absolute maximum and the absolute minimum of the function f(x,y) = 6 - x² - y² over the region R = {(x,y) | -2 <= x <= 2, -1 <= y <= 1 }. Also mention the points at which the maximum and minimum will occur.
In MATLAB write a function secant.m to apply the secant method. function [x,i] = secant(f, x0,...
In MATLAB write a function secant.m to apply the secant method. function [x,i] = secant(f, x0, x1, tol, maxiters) [x,i] = secant(f, x0, x1, tol, maxiters) performs the secant method with f(x), starting at x_0 = x0 and x_1 = x1, and continuing until either |x_i+1 - x_i| <= tol, or maxiters iterations have been taken. The number of iterations, i, is also returned. An error is raised if the first input is not a function handle. A warning is...
Matlab Consider f(x) = x^3 - x. Plot it. (a) Use Newton's method with p_0 =1.5...
Matlab Consider f(x) = x^3 - x. Plot it. (a) Use Newton's method with p_0 =1.5 to find an approximation to a root with tolerance TOL = 0.01. (b) Use secant method with p_0 = 0.5 , p_1 =1.5, to answer same question as (a). (c) Use Method of False position with initial approximate roots as in (b).
Find the absolute maximum and minimum values for the function f(x, y) = xy on the...
Find the absolute maximum and minimum values for the function f(x, y) = xy on the rectangle R defined by −8 ≤ x ≤ 8, −8 ≤ y ≤ 8.
For the function f(x) = x(x+1) find the exact formula for f′(x). Use only the definition...
For the function f(x) = x(x+1) find the exact formula for f′(x). Use only the definition of the derivative.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT