Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
540 B
1
Indexable
Never
function t = fibonacci(x)
n(1)=1;
n(2)=1;
for i =3:x
   n(i)=n(i-2)+n(i-1);
end
t=n(x);
end
function [s,ot] = fibmetod(f, a, b, n)

x1=a+(b-a)*(fibonacci(n-2)/fibonacci(n));

x2=a+(b-a)*(fibonacci(n-1)/fibonacci(n));
    
    
while(n > 1)
    n=n-1;
    y1=feval(f,x1);
    y2=feval(f,x2);
    if(y1<y2)
        b = x2;
        x2=x1;
        x1=a+(b-a)(fibonacci(n-2)/fibonacci(n));
    else
        a=x1;
        x1=x2;
        x2=a+(b-a)(fibonacci(n-1)/fibonacci(n));
    end
end
s=x1;
ot=feval(f,x1);
end