Code covered by the BSD License  

Highlights from
slatec

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

[airesult,x]=ai(x);
function [airesult,x]=ai(x);
airesult=[];
persistent ai aifcs aigcs first firstCall naif naig theta x3sml xm xmax xmaxt z ; if isempty(firstCall),firstCall=1;end; 

if isempty(airesult), airesult=0; end;
if isempty(aifcs), aifcs=zeros(1,9); end;
if isempty(aigcs), aigcs=zeros(1,8); end;
if isempty(theta), theta=0; end;
if isempty(x3sml), x3sml=0; end;
if isempty(xm), xm=0; end;
if isempty(xmax), xmax=0; end;
if isempty(xmaxt), xmaxt=0; end;
if isempty(z), z=0; end;
if isempty(naif), naif=0; end;
if isempty(naig), naig=0; end;
%***BEGIN PROLOGUE  AI
%***PURPOSE  Evaluate the Airy function.
%***LIBRARY   SLATEC (FNLIB)
%***CATEGORY  C10D
%***TYPE      SINGLE PRECISION (AI-S, DAI-D)
%***KEYWORDS  AIRY FUNCTION, FNLIB, SPECIAL FUNCTIONS
%***AUTHOR  Fullerton, W., (LANL)
%***DESCRIPTION
%
% AI(X) computes the Airy function Ai(X)
% Series for AIF        on the interval -1.00000D+00 to  1.00000D+00
%                                        with weighted error   1.09E-19
%                                         log weighted error  18.96
%                               significant figures required  17.76
%                                    decimal places required  19.44
%
% Series for AIG        on the interval -1.00000D+00 to  1.00000D+00
%                                        with weighted error   1.51E-17
%                                         log weighted error  16.82
%                               significant figures required  15.19
%                                    decimal places required  17.27
%
%***REFERENCES  (NONE)
%***ROUTINES CALLED  AIE, CSEVL, INITS, R1MACH, R9AIMP, XERMSG
%***REVISION HISTORY  (YYMMDD)
%   770701  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)
%   920618  Removed space from variable names.  (RWC, WRB)
%***end PROLOGUE  AI
if isempty(first), first=false; end;
if firstCall,   aifcs(1)=[-.03797135849666999750e0];  end;
if firstCall,   aifcs(2)=[.05919188853726363857e0];  end;
if firstCall,   aifcs(3)=[.00098629280577279975e0];  end;
if firstCall,   aifcs(4)=[.00000684884381907656e0];  end;
if firstCall,   aifcs(5)=[.00000002594202596219e0];  end;
if firstCall,   aifcs(6)=[.00000000006176612774e0];  end;
if firstCall,   aifcs(7)=[.00000000000010092454e0];  end;
if firstCall,   aifcs(8)=[.00000000000000012014e0];  end;
if firstCall,   aifcs(9)=[.00000000000000000010e0];  end;
if firstCall,   aigcs(1)=[.01815236558116127e0];  end;
if firstCall,   aigcs(2)=[.02157256316601076e0];  end;
if firstCall,   aigcs(3)=[.00025678356987483e0];  end;
if firstCall,   aigcs(4)=[.00000142652141197e0];  end;
if firstCall,   aigcs(5)=[.00000000457211492e0];  end;
if firstCall,   aigcs(6)=[.00000000000952517e0];  end;
if firstCall,   aigcs(7)=[.00000000000001392e0];  end;
if firstCall,   aigcs(8)=[.00000000000000001e0];  end;
if firstCall,   first=[true];  end;
firstCall=0;
%***FIRST EXECUTABLE STATEMENT  AI
if( first )
[naif ,aifcs]=inits(aifcs,9,0.1.*r1mach(3));
[naig ,aigcs]=inits(aigcs,8,0.1.*r1mach(3));
%
x3sml = r1mach(3).^0.3334;
xmaxt =(-1.5.*log(r1mach(1))).^0.6667;
xmax = xmaxt - xmaxt.*log(xmaxt)./(4.0.*sqrt(xmaxt)+1.0) - 0.01;
end;
first = false;
%
if( x<(-1.0) )
[x,xm,theta]=r9aimp(x,xm,theta);
airesult = xm.*cos(theta);
csnil=dbstack(1); csnil=csnil(1).name(1)~='@';
if csnil&&~isempty(inputname(1)), assignin('caller','FUntemp',x); evalin('caller',[inputname(1),'=FUntemp;']); end
return;
%
elseif( x<=1.0 ) ;
z = 0.0;
if( abs(x)>x3sml )
z = x.^3;
end;
airesult = 0.375 +(csevl(z,aifcs,naif)-x.*(0.25+csevl(z,aigcs,naig)));
csnil=dbstack(1); csnil=csnil(1).name(1)~='@';
if csnil&&~isempty(inputname(1)), assignin('caller','FUntemp',x); evalin('caller',[inputname(1),'=FUntemp;']); end
return;
%
elseif( x>xmax ) ;
%
airesult = 0.0;
xermsg('SLATEC','AI','X SO BIG AI UNDERFLOWS',1,1);
else;
airesult = aie(x).*exp(-2.0.*x.*sqrt(x)./3.0);
csnil=dbstack(1); csnil=csnil(1).name(1)~='@';
if csnil&&~isempty(inputname(1)), assignin('caller','FUntemp',x); evalin('caller',[inputname(1),'=FUntemp;']); end
return;
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 ALBETA

Contact us at files@mathworks.com