%Grafik Yöntem
clear all; clc;close all;
i=1;
for theta=0:pi/200:pi/4
f(i)=tan(theta)*5-9.81*5^2/(2*10^2*cos(theta)^2)-3.05+2.5;
i=i+1;
end;
plot([0:pi/200:pi/4]*180/pi,f)
calt=20*pi/180;cust=22*pi/180; 
% Be deðerleri grafik yöntemle yaptýðýmýz çözüm 
% doðrultusunda keyfi olarak belirledik;
while cust-calt>0.00001
cr=(calt+cust)/2;i=1;
for theta=[calt cr cust]
    F(i)=tan(theta)*5-9.81*5^2/(2*10^2*cos(theta)^2)-3.05+2.5;
    i=i+1;
end
if F(1,1)*F(1,2)<0
    cust=cr;
elseif F(1,3)*F(1,2)<0
    calt=cr;
elseif F(1,3)*F(1,2)==0
    break
end
end
sprintf('Çözüm=%5f ',cr*180/pi)
sprintf('Çözümün saðlamasý=%5f',F(1,2))
%%Ýkiye Ayýrma Yöntemi
clear all; 
calt=20*pi/180;cust=22*pi/180; i=1;
for theta=[calt cust]
    F(i)=tan(theta)*5-9.81*5^2/(2*10^2*cos(theta)^2)-3.05+2.5;
    i=i+2;
end
while cust-calt>0.001
cr=cust-(F(1,3)*(calt-cust))/(F(1,1)-F(1,3));i=1; %Ýkiye Ayýrma Yöntemi
for theta=[calt cr cust]
F(i)=5*tan(theta)-9.81*5^2/(2*10^2*cos(theta)*cos(theta))-3.05+2.5;
    i=i+1;
end
if F(1,1)*F(1,2)<0
    cust=cr;
elseif F(1,3)*F(1,2)<0
    calt=cr;
elseif F(1,3)*F(1,2)==0
    break
end
end
sprintf('Çözüm=%5f ',cr*180/pi)
sprintf('Çözümün saðlamasý=%5f',F(1,2))