Professional Documents
Culture Documents
Problem 01
Problem 01
clear all
f=@(x) (1-((log(1+x^2))/(1+x^2)));
fplot(f,[0.1,5]);
epsilon=1e-10;
a=0.1; d=5;
icount=0;maxIterations=100;
while abs(a-d) > epsilon
icount=icount+1;
%for n=1:10
b=a+(d-a)/3;
c=d-(d-a)/3;
if f(c)<f(b)
a=b;
else
d=c;
end
end
xMin=(a+d)/2;
minVal=f(xMin);
figure
fplot(f,[0.1,5],'-b');
grid on;
[xsoln,fxsoln]=fminsearch(f,1)
f(xsoln)
[xsoln2,fxsoln2]=fminbnd(f,0,1.5)
f(xsoln2)