Code covered by the BSD License  

Highlights from
slatec

from slatec by Ben Barrowes
The slatec library converted into matlab functions.

[alnrelresult,x]=alnrel(x);
function [alnrelresult,x]=alnrel(x);
alnrelresult=[];
persistent alnrcs alnrel first firstCall nlnrel xmin ; if isempty(firstCall),firstCall=1;end; 

if isempty(alnrcs), alnrcs=zeros(1,23); end;
if isempty(alnrelresult), alnrelresult=0; end;
if isempty(xmin), xmin=0; end;
if isempty(nlnrel), nlnrel=0; end;
%***BEGIN PROLOGUE  ALNREL
%***PURPOSE  Evaluate ln(1+X) accurate in the sense of relative error.
%***LIBRARY   SLATEC (FNLIB)
%***CATEGORY  C4B
%***TYPE      SINGLE PRECISION (ALNREL-S, DLNREL-D, CLNREL-C)
%***KEYWORDS  ELEMENTARY FUNCTIONS, FNLIB, LOGARITHM
%***AUTHOR  Fullerton, W., (LANL)
%***DESCRIPTION
%
% ALNREL(X) evaluates ln(1+X) accurately in the sense of relative
% error when X is very small.  This routine must be used to
% maintain relative error accuracy whenever X is small and
% accurately known.
%
% Series for ALNR       on the interval -3.75000D-01 to  3.75000D-01
%                                        with weighted error   1.93E-17
%                                         log weighted error  16.72
%                               significant figures required  16.44
%                                    decimal places required  17.40
%
%***REFERENCES  (NONE)
%***ROUTINES CALLED  CSEVL, INITS, R1MACH, XERMSG
%***REVISION HISTORY  (YYMMDD)
%   770401  DATE WRITTEN
%   890531  Changed all specific intrinsics to generic.  (WRB)
%   890531  REVISION DATE from Version 3.2
%   891214  Prologue converted to Version 4.0 format.  (BAB)
%   900315  CALLs to XERROR changed to CALLs to XERMSG.  (THJ)
%   900326  Removed duplicate information from DESCRIPTION section.
%           (WRB)
%***end PROLOGUE  ALNREL
if isempty(first), first=false; end;
if firstCall,   alnrcs(1)=[1.0378693562743770e0];  end;
if firstCall,   alnrcs(2)=[-.13364301504908918e0];  end;
if firstCall,   alnrcs(3)=[.019408249135520563e0];  end;
if firstCall,   alnrcs(4)=[-.003010755112753577e0];  end;
if firstCall,   alnrcs(5)=[.000486946147971548e0];  end;
if firstCall,   alnrcs(6)=[-.000081054881893175e0];  end;
if firstCall,   alnrcs(7)=[.000013778847799559e0];  end;
if firstCall,   alnrcs(8)=[-.000002380221089435e0];  end;
if firstCall,   alnrcs(9)=[.000000416404162138e0];  end;
if firstCall,   alnrcs(10)=[-.000000073595828378e0];  end;
if firstCall,   alnrcs(11)=[.000000013117611876e0];  end;
if firstCall,   alnrcs(12)=[-.000000002354670931e0];  end;
if firstCall,   alnrcs(13)=[.000000000425227732e0];  end;
if firstCall,   alnrcs(14)=[-.000000000077190894e0];  end;
if firstCall,   alnrcs(15)=[.000000000014075746e0];  end;
if firstCall,   alnrcs(16)=[-.000000000002576907e0];  end;
if firstCall,   alnrcs(17)=[.000000000000473424e0];  end;
if firstCall,   alnrcs(18)=[-.000000000000087249e0];  end;
if firstCall,   alnrcs(19)=[.000000000000016124e0];  end;
if firstCall,   alnrcs(20)=[-.000000000000002987e0];  end;
if firstCall,   alnrcs(21)=[.000000000000000554e0];  end;
if firstCall,   alnrcs(22)=[-.000000000000000103e0];  end;
if firstCall,   alnrcs(23)=[.000000000000000019e0];  end;
if firstCall,   first=[true];  end;
firstCall=0;
%***FIRST EXECUTABLE STATEMENT  ALNREL
if( first )
[nlnrel ,alnrcs]=inits(alnrcs,23,0.1.*r1mach(3));
xmin = -1.0 + sqrt(r1mach(4));
end;
first = false;
%
if( x<=(-1.0) )
xermsg('SLATEC','ALNREL','X IS LE -1',2,2);
end;
if( x<xmin )
xermsg('SLATEC','ALNREL','ANSWER LT HALF PRECISION BECAUSE X TOO NEAR -1',1,1);
end;
%
if( abs(x)<=0.375 )
alnrelresult = x.*(1.-x.*csevl(x./.375,alnrcs,nlnrel));
end;
if( abs(x)>0.375 )
alnrelresult = log(1.0+x);
end;
%
csnil=dbstack(1); csnil=csnil(1).name(1)~='@';
if csnil&&~isempty(inputname(1)), assignin('caller','FUntemp',x); evalin('caller',[inputname(1),'=FUntemp;']); end
end
%DECK ASINH

Contact us at files@mathworks.com