c = 299792.458 ;
A1=15600;
B1=7540;
C1=20140;
A2=18760;
B2=2750;
C2=18610;
A3=17610;
B3=14630;
C3=13480;
A4=19170;
B4=610;
C4=18390;
t1=0.07074;
t2=0.07220;
t3=0.07690;
t4=0.07242;


n=10;
    x0=[0; 0; 6370; 0]
    
for i=1:n;
        x = x0(1);
        y = x0(2);
        z = x0(3);
        d = x0(4);
        F=[(x-A1)^2+(y-B1)^2+(z-C1)^2-[c*(t1-d)]^2;
    (x-A2)^2+(y-B2)^2+(z-C2)^2-[c*(t2-d)]^2;
    (x-A3)^2+(y-B3)^2+(z-C3)^2-[c*(t3-d)]^2;
    (x-A4)^2+(y-B4)^2+(z-C4)^2-[c*(t4-d)]^2;];
        F
        DF = [2*(x-A1) 2*(y-B1) 2*(z-C1) 2*c^2*(t1-d);
    2*(x-A2) 2*(y-B2) 2*(z-C2) 2*c^2*(t2-d);
    2*(x-A3) 2*(y-B3) 2*(z-C3) 2*c^2*(t3-d);
    2*(x-A4) 2*(y-B4) 2*(z-C4) 2*c^2*(t4-d)];
        v=DF\(-1*F);
        DF
        x0=x0+v;
        x0
end
