clear
fplot(@(T)0.92+T/20+(0.00004*(T^3))-0.9/10,[-20,10])
grid on
legend('d=10*(0.92+T/20+(0.00004*(T^3)))')
title('Joonis alglähendite leidmiseks')
xlabel('T(temperatuur)')
ylabel('d(diameeter)')
%Jooniselt fplot(0.9) on näha, et võrrandil on üks lahend kus T=0.Valime alglähendiks
%-14.2 
d=0.9;
f=@(T)0.92+0.05*T+(0.00004*(T^3))-(d/10); %%%%%%%%%%%%0.92 asemel peaks teine konstant olema
ftuletis=@(T)1/20+(0.000012*(T^2)); %Newtoni meetodi jaoks %%%%%%%%%%%%%%%%%%%%%%%%%

%Kontrollin HIM jaoks koonduvust
%Avaldan T g(T)=20*(0.9/10-0.92-(0.00004*(T^3)))
%Tuletis g'(T)=-(0.000006*(T^2)) %%%%%%%%%%%%%%%%%%T^2 ees vale konstant
T=-14.2;
tuletis1=abs(-(0.0024*(T^2))) %=0.4839 <1 SOBIB
%HIM lahendus
T=-14.2;
i=0;
while abs(f(T))>10^-5
T=(-1.8-18.4-(0.0008*(T^3)))
i=i+1;
end
lahendHIM=T
sammudHIM=i