function MyTaylor()

clear all
close all

I = [-4 4];
N  = 3;
x0 = 2;
x  = I(1):0.01:I(2);

ye = DSQRT(x,0);
y  = MyTaylorPolynom(x,@DSQRT,x0,N);

plot(x,ye,'k-',x,y,'b-');
ylim([-1 1]);
grid on


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
