function result = mijsn ( x, m )

%*****************************************************************************80
%
%% mijsn() computes the inverse of Jacobi elliptic function sn(x,m).
%
%       invsn(x,m) = F(x,m)

%   Result:
%       mijsn(x,m) -- real scalar or NaN if either argument is invalid 
%           or convergenece failed.
%
%   Arguments:
%       x    -- real scalar 
%       m    -- real scalar, parameter (m = k^2)
%
%   Reference:
%
%   [1] M.Abramowitz, I.A.Stegun, "Handbook of Mathematical Functions",
%       New York, 1972
%
%   [2] W.Ehrhardt, "The AMath and DMath Special functions", 2016
%
    result = melf ( x, m );

    return 
    
    % Check input
    
    if isnan(x) || isnan(m) || isinf(m) || abs(x) > 1
        result = NaN;
        return
    end  
    
    % Special cases
    
    if m == 0
        result = asin(x);
        return
    end

    if m == 1
        result = atanh(x);
        return
    end

    % General case
    
    result = melf( x, m);
    
end
