Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear
- clc
- x0=input('Dati X0:')
- d=input('Dati pasul d:');
- x1=x0;
- f1=f(x1);
- x2=x1+d;
- f2=f(x2);
- if f1>f2
- while f1>f2
- d=2*d;
- x1=x2;
- x2=x1+d;
- f1=f2;
- f2=f(x2);
- x1
- x2
- f(x1)
- f(x2)
- end
- xs=x1-d/2;
- xd=x2;
- xs
- xd
- elseif f2>f1
- d=-d;
- x2=x1+d;
- f2=f(x2);
- while f2>f1
- d=2*d;
- f1=f2;
- x1=x2;
- f1=f2;
- x1=x1-d;
- f2=f(x2);
- x1
- x2
- f(x1)
- f(x2)
- return;
- end
- elseif (f2==f1)
- d=2*d;
- x1=x2;
- f1=f2;
- x1
- x2
- f(x1)
- f(x2)
- return;
- end
- x1
- x2
- f(x1)
- f(x2)
- xs=x1-d/2;
- xd=x2;
- xs
- xd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement