function [ ] = Assignment3()
%Assignment3 Matlab assignment 3
%%%%%%%%%%%%FUNCTIONS SECTION%%%%%%%%%%%%%%%%%%%%%
%%%%%DO NOT PUT CODE OUTSDIDE OF FUNCTIONS HERE%%%

%%
%Write a function that finds zeros by bisection
%INPUT:   f : a continuous function of one variable
%       a,b : numbers such that the signs of f(a) and f(b) are opposite
%   epsilon : wanted precision (a small number)        
%OUTPUT:  x : a number such that |f(x)|<epsilon
%    nsteps : number of steps it took to reach x
    function [x, nsteps] = find_zero_bisection(f, a, b, epsilon)
        if (sign(f(a)) ~= sign(f(b)))
           mid = (a+b)/2;
            val = f(mid);
            nsteps = 0;       
            while (abs(val) > epsilon)          
            %>PUT CODE HERE
            end
            x = mid;
       end           
    end


%%
%Finding zeros by Newton's method
%INPUT:   f : a differentiable function of one variable
%        x0 : an initial guess for the root
%   epsilon : wanted precision (a small number)        
%OUTPUT:  x : a number such that |f(x)|<epsilon
%    nsteps : number of steps it took to reach x
    function [x, nsteps] = find_zero_Newton(f, x0, epsilon)


    end


%%
%Write a function that draws the involute of a curve (fx(t), fy(t)) starting form
%t=t0 to t=t1
    function draw_involute(fx, fy, t0, t1)
        
        
    end



%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%
%Testing the bisection: test 1
    %f  =  @(x) x.^2 - 8;
    %[root, nsteps] = find_zero_bisection(f, 0, 5, 0.0001)

%%
%Testing the bisection: test 2
    %f  = @(x) 6 - x.^2;
    %[root, nsteps] = find_zero_bisection(f, 0, 5, 0.0001)
    
    
%%
%Testing Newton's
    %f  =  @(x) x.^2 - 8;
    %[root, nsteps] = find_zero_Newton(f, 2.5, 0.0001)

%%
%   Let a_n = 0.1/2^n, and b_n = nsteps from calling
%   find_zero_bisection(f,0,5,a_n) for f  =  @(x) x.^2 - 8;
%   Plot n vs b_n for n = 1..40

%figure('Name', 'Bisection step count');


%%
%   Let a_n = 0.1/2^n, and b_n = nsteps from calling
%   find_zero_Newton(f,2.5,a_n) for f  =  @(x) x.^2 - 8;
%   Plot n vs b_n for n = 1..40
    
%%figure('Name', 'Newton's step count');
    
%%
%Testing the involute
%figure('Name', 'Involute of a parabola');
%fx(t) = @(t) ...
%fy(t) = @(t) ...
%Plot the parabola:
%t = [-3:0.001:3];
%plot(fx(t), fy(t))
%draw_involute(fx,fy,0,3);

%%
%Extra Credit (Worth 1/4 of lab)
% Let a_n = the volume of n-dimensional sphere. Compute a_n for n = 1..10

end

