Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function wynik = minX(y)
- %UNTITLED3 Summary of this function goes here
- % Detailed explanation goes here
- stala = y;
- f=@(x) 2.*x.^2+stala.^2+x.*stala-6.*x-5.*stala+8;
- %x = -5:0.1:5;
- a = -5;
- b = 5;
- e = 0.000001;
- x1=a+0.382*(b-a);
- x2=a+0.618*(b-a);
- while (b-a)>e
- if (f(x1)<f(x2))
- b=x2;
- else
- a=x1;
- end
- x1=a+0.382*(b-a);
- x2=a+0.618*(b-a);
- end;
- wynik=(a+b)/2;
- end
Add Comment
Please, Sign In to add comment