function v=part2(s)
%initialize u vectors and c
c=299792.458;
ux=zeros(3,1);
uy=zeros(3,1);
uz=zeros(3,1);
ud=zeros(3,1);
w=zeros(3,1);

%constructing u vectors
for i=1:3
    ux(i)=(2*s(i+1,1)-2*s(1,1));
    uy(i)=(2*s(i+1,2)-2*s(1,2));
    uz(i)=(2*s(i+1,3)-2*s(1,3));
    ud(i)=(2*s(1,4)*(c^2)-2*s(i+1,4)*(c^2));
    w(i)=(s(1,1)^2-s(i+1,1)^2+s(1,2)^2-s(i+1,2)^2+s(1,3)^2-s(i+1,3)^2-((c^2)*(s(1,4)^2))+(c^2)*(s(i+1,4)^2));
end

%making determinants for our linear equations
A1=det([uy uz ux]);
A2=det([ux uz uy]);
A3=det([ux uy uz]);
D1=det([uy uz ud]);
D2=det([ux uz ud]);
D3=det([ux uy ud]);
W1=det([uy uz w]);
W2=det([ux uz w]);
W3=det([ux uy w]);

%bisection method
%initial guesses -1 and 1
guess1=-1;
guess2=1;
tol=.5e-13;
%please see f2 file for f2 function
fguess1=f2(guess1,A1,A2,A3,D1,D2,D3,W1,W2,W3,s(1,1),s(1,2),s(1,3),s(1,4));
fguess2=f2(guess2,A1,A2,A3,D1,D2,D3,W1,W2,W3,s(1,1),s(1,2),s(1,3),s(1,4));
while (guess2-guess1)/2>tol
  c=(guess2+guess1)/2;
  fc=f2(c,A1,A2,A3,D1,D2,D3,W1,W2,W3,s(1,1),s(1,2),s(1,3),s(1,4));
  if fc == 0              %c is a solution, done
    break
  end
  if sign(fc)*sign(fguess1)<0  %a and c make the new interval
    guess2=c;fguess2=fc;
  else                    %c and b make the new interval
    guess1=c;fguess1=fc;
  end
end
d=(guess1+guess2)/2;               %new midpoint is best estimate

%back solve for the things I want
x=(-W1-d*D1)/A1;
y=(-W2-d*D2)/A2;
z=(-W3-d*D3)/A3;

%output the answer
v=[x y z d];



