function TutoTaylor()
    clear all
    close all
    
    N = 20;
    x0 = 1;
    
    x = 0.01:0.01:3;
    ye = DSQRT(x,0);
    y = TaPoSQRT(x,x0,N);
    
    plot(x,ye,'k-',x,y,'b-');
    ylim([0 sqrt(max(x))]);
    grid on
end


function y=TaPoSQRT(x,x0,n)

y=0;
for k=0:n
    y = y + DSQRT(x0,k)/factorial(k)*(x-x0).^k;
end

end


function y=DSQRT(x,n)

switch n
    case 0
        y=sqrt(x);
    case 1
        y=1/2./sqrt(x);
    otherwise
        prod=1;
        for j=0:n-2
            prod = prod*(2*j+1);
        end
        y = (-1)^(n+1)/2^n*prod./(sqrt(x).^(2*n-1));
end
    
end

