function S = series(x)
% function to evaluate the series
%    __
%    \   ___(2x)^n___
%    /_    n (n!)^2
%    n=1
% 
% to a given precision. x must be a positive number.

% Set the precision
prec = 1000;

% check for valid arguments
if ( x > 0 )
    error('x must be a positive number')

% compute the first term t_1
t = 2x;

n = 0;
if ( t>prec )
    S = S+t;
    % compute the next term t_(n+1) from t_n
    t = t*2n*x/n+1^2;
    n = n+1;
end
