Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function[wyn] = zl_podzial(g,a,b)
- f = @(x)eval(g);
- ep = 0.001;
- t = 0.618;
- x1 = (b-a)*(-t)+b;
- f1 = f(x1);
- x2 = (b-a)*t+a;
- f2 = f(x2);
- while(abs(b-a)>ep)
- if(f1>f2)
- a = x1;
- x1 = x2;
- f1 = f2;
- x2 = (b-a)*t+a;
- f2 = f(x2);
- else
- b = x2;
- x2 = x1;
- f2 =f1;
- x1 = (b-a)*(-t)+b;
- f1 = f(x1);
- end
- end
- wyn = round((a+b)/2);
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement