% T1 - 1st order
% T2 - 2nd order
function Tnew = solve1stOrderAnd2ndOrder(T1, T2, F)

discrim = 13*F*F + 6*T1*T2 - T2*T2 - 9*T1*T1;
if discrim > 0
    Tnew = 3/13*T2 + 4/13*T1 + 2/13*sqrt(discrim);
else
    Tnew = min((2*F + T2)/3, F + T1);
end
