
warning('OFF', 'all');

% parts 1 and 3

satellites = [
    15600, 7540, 10380, 0.05932;
    11760, 2750, 16190, 0.05192;
    11610, 14630, 7680, 0.06242;
    15170, 610, 13320, 0.05571];

algebraic_solution = SolveGPS(satellites)
newtons_method_solution = NewtonsMethodGPS(satellites, [0, 0, 6370, 0], 100)


% part 4

random_satellites = [
    pi/4, pi;
    pi/6, pi/4;
    0.2, 5;
    1, 2.5];

number_of_trials = 10;
trials = zeros(number_of_trials, 2);
for i = 1 : number_of_trials
    [error, emf] = EMF(random_satellites, 10e-8);
    trials(i, 1) = error; trials(i, 2) = emf;
end

display('4 random satellite results:');
average_position_error4 = sum(trials(:, 1))/number_of_trials
average_emf4 = sum(trials(:, 2))/number_of_trials
max_position_error4 = max(trials(:, 1))
max_emf4 = max(trials(:, 2))
display(' ');
display(' ');


% part 5

bunched_satellites = [
    .97, 6.2832;
    1.01, 5.960;
    1.05, 6.1052;
    1.03, 5.9750];

trials = zeros(number_of_trials, 2);
for i = 1 : number_of_trials
    [error, emf] = EMF(bunched_satellites, 10e-8);
    trials(i, 1) = error; trials(i, 2) = emf;
end

display('4 bunched satellite results:');
average_position_error5 = sum(trials(:, 1))/number_of_trials
average_emf5 = sum(trials(:, 2))/number_of_trials
max_position_error5 = max(trials(:, 1))
max_emf5 = max(trials(:, 2))
display(' ');
display(' ');


% part 6

random_satellites = [
    random_satellites;
    0.45, 4.5;
    0.1, 2;
    1.5, 3.5;
    pi/2.1, 6;
    0.75, 3;
    1.1, 4.2];

trials = zeros(number_of_trials, 2);
for i = 1 : number_of_trials
    [error, emf] = EMF(random_satellites, 10e-8);
    trials(i, 1) = error; trials(i, 2) = emf;
end

display('10 random satellite results:');
average_position_error6 = sum(trials(:, 1))/number_of_trials
average_emf6 = sum(trials(:, 2))/number_of_trials
max_position_error6 = max(trials(:, 1))
max_emf6 = max(trials(:, 2))




