%uloha 118 a
f = @(x) x.^2+exp(x-2)-x-3;
x = -10:.01:10; plot(x,f(x))
x = -10:.01:10; plot(x,f(x),x,x*0,'g')

%nelezeni jednoho korenu metodou puleni intervalu (fce puleni), metodou tetiv (fce
%RegulaFalsi) a Newtonovou metodou (fce Newton)

koren1 = puleni(f,-2,-0.5,1e-5) 
koren2 = RegulaFalsi(f,-2,-0.5,1000,1e-5,1e-5)
koren3 = Newton(f,-2,-0.5,-2,1000,1e-5,1e-5)

%presny vysledek
syms t
y=f(t); solve(y)

%nalezeni dalsiho korenu v jiném intervalu (viz graf)
koren1 = puleni(f,-.5,3,1e-5)
koren2 = RegulaFalsi(f,.5,3,1000,1e-5,1e-5)
koren3 = Newton(f,.5,3,1,1000,1e-5,1e-5)

%nalezeni korene pomoci knihovni funkce fzero v okoli prislusnych bodu
fzero(f,-1)
fzero(f,2)

% moznosti overeni vysledku
feval(f,2)
f(2)
