Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function[x] = Polowa(a,b,g)
- ep = 0.001;
- while(abs(b-a)>ep)
- f = @(x)eval(g);
- xm = (a+b)/2;
- L = b - a;
- x1 = a + (L/4);
- x2 = b - (L/4);
- if(f(x1)<f(xm))
- b =xm;
- L = b - a;
- else if(f(x2)<f(xm))
- a =xm;
- L = b-a;
- xm = x2;
- else
- a = x1;
- b = x2;
- L = b - a;
- end
- end
- end
- x = (a+b)/2;
- end
Advertisement
Add Comment
Please, Sign In to add comment