Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

ASSIGNMENT - 2

NUMERICAL AND ENGINEERING OPTIMIZATION METHODS

Abhishek Kumar Choudhary , 2K21/EE/15

Problem

Solve these equations using Fibonacci Methods :

1. 2. 3.

For solving these equations we use fibonacci methods ,

MATLAB - CODE
@main script file @ Fibonacci file

clc; function fibb = fibb(n)


a=1; solv(1)=1;
b=7; solv(2)=2;
n=11; for i=3:n
fixed = b-a; solv(i)=solv(i-1)+solv(i-2);
k=2; end
fprintf('k\tlk\t\t\tx1\t\t\ty1\t\t\tx2\t\t\ty2\n'); fibb=solv(n);
while k<=n end
lk = (fibb(n-k+1)/fibb(n+1))*fixed;
x1 = a+lk;
x2 = b-lk;
y1 = eqn(x1);
y2 = eqn(x2);

fprintf('%d\t%f\t%f\t%f\t%f\t%f\n',k,lk,x1,y1,x2,y2);
if x1==x2
continue;
elseif y1>y2
a=x1;
elseif y2>y1
b=x2;
end
k=k+1;
end

these two file remains same , the equations file need to change for every equations;
Problem 1 Problem 2 Problem 3

function eqn = eqn(x) function eqn = eqn(x) function eqn = eqn(x)


eqn = eqn = (x^2+10*x+25)/(100*x); eqn =
(5*x^2-50*x+125)/(x^2+10*x+ end (-100*x)/(x^2+10*x+25);
25);end end
Iterations for these problems:
Problem 1:
k lk x1 y1 x2 y2
2 2.291845 3.291845 0.212189 4.708155 0.004519
3 1.416309 4.708155 0.004519 5.583691 0.015208
4 0.875536 4.167382 0.041245 4.708155 0.004519
5 0.540773 4.708155 0.004519 5.042918 0.000091
6 0.334764 5.042918 0.000091 5.248927 0.002950
7 0.206009 4.914163 0.000375 5.042918 0.000091
8 0.128755 5.042918 0.000091 5.120172 0.000705
9 0.077253 4.991416 0.000004 5.042918 0.000091
10 0.051502 4.965665 0.000059 4.991416 0.000004
11 0.025751 4.991416 0.000004 5.017167 0.000015

Problem 2:
k lk x1 y1 x2 y2
2 2.291845 3.291845 0.208864 4.708155 0.200181
3 1.416309 4.708155 0.200181 5.583691 0.200610
4 0.875536 4.167382 0.201664 4.708155 0.200181
5 0.540773 4.708155 0.200181 5.042918 0.200004
6 0.334764 5.042918 0.200004 5.248927 0.200118
7 0.206009 4.914163 0.200015 5.042918 0.200004
8 0.128755 5.042918 0.200004 5.120172 0.200028
9 0.077253 4.991416 0.200000 5.042918 0.200004
10 0.051502 4.965665 0.200002 4.991416 0.200000
11 0.025751 4.991416 0.200000 5.017167 0.200001

Problem 3:
k lk x1 y1 x2 y2
2 2.291845 3.291845 -4.787811 4.708155 -4.995481
3 1.416309 4.708155 -4.995481 5.583691 -4.984792
4 0.875536 4.167382 -4.958755 4.708155 -4.995481
5 0.540773 4.708155 -4.995481 5.042918 -4.999909
6 0.334764 5.042918 -4.999909 5.248927 -4.997050
7 0.206009 4.914163 -4.999625 5.042918 -4.999909
8 0.128755 5.042918 -4.999909 5.120172 -4.999295
9 0.077253 4.991416 -4.999996 5.042918 -4.999909
10 0.051502 4.965665 -4.999941 4.991416 -4.999996
11 0.025751 4.991416 -4.999996 5.017167 -4.999985
plots

You might also like