function I = IntLn(L)

fprintf('\n\n       Homework #3, Problem 4 ');
fprintf('\n\n Integral of ln(1+x) from 0 to %g', L);
fprintf('\n\n I(%g) = Sum for n=1..m of (-1)^(n+1) %g^(n+1)/(n (n+1))\n\n',L,L);

tolerance = 1e-5;
I = 0;
for n=1:1000
    an = (-1)^(n+1) * L^(n+1) / (n * (n + 1));
    I = I + an;
    if  abs(an) < tolerance  break
    end;
end;

fprintf(' Result = %.7g, Number of terms used = %d\n\n', I, n);
x=sym('x'); 
exact = quad('log(x+1)',0,L);  % "quad" is the Matlab's integrator ("quad"
                               % stands for "quadrature", which means integral)
fprintf(' Compare with exact result: %.8g \n', exact);