function MyTaylor()

clear all
close all

I = [0.5 2];
N = 20;
x0 = 1;%5/4;
DIM = 151;
h = (I(2)-I(1))/(DIM-1);
x  = I(1):h:I(2);

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

Error = norm(y-ye,inf)
fInt = MyTaylorIntegral(@DLN,x0,N,I(1),I(2))
%exakter Wert des Integrals auf 15 Nachkommastellen 0.465735902799727


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

end


function y=DLN(x,n)

switch n
    case 0
        y=log(x.^2);
    otherwise
        y=2*(-1)^(n-1)*factorial(n-1)./x.^n;
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
