function [biresult,x]=bi(x);
biresult=[];
persistent bi bif2cs bifcs big2cs bigcs eta first firstCall nbif nbif2 nbig nbig2 theta x3sml xm xmax z ; if isempty(firstCall),firstCall=1;end;
if isempty(biresult), biresult=0; end;
if isempty(bif2cs), bif2cs=zeros(1,10); end;
if isempty(bifcs), bifcs=zeros(1,9); end;
if isempty(big2cs), big2cs=zeros(1,10); end;
if isempty(bigcs), bigcs=zeros(1,8); end;
if isempty(eta), eta=0; 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(z), z=0; end;
if isempty(nbif), nbif=0; end;
if isempty(nbif2), nbif2=0; end;
if isempty(nbig), nbig=0; end;
if isempty(nbig2), nbig2=0; end;
%***BEGIN PROLOGUE BI
%***PURPOSE Evaluate the Bairy function (the Airy function of the
% second kind).
%***LIBRARY SLATEC (FNLIB)
%***CATEGORY C10D
%***TYPE SINGLE PRECISION (BI-S, DBI-D)
%***KEYWORDS BAIRY FUNCTION, FNLIB, SPECIAL FUNCTIONS
%***AUTHOR Fullerton, W., (LANL)
%***DESCRIPTION
%
% BI(X) calculates the Airy function of the second kind for real
% argument X.
%
% Series for BIF on the interval -1.00000D+00 to 1.00000D+00
% with weighted error 1.88E-19
% log weighted error 18.72
% significant figures required 17.74
% decimal places required 19.20
%
% Series for BIG on the interval -1.00000D+00 to 1.00000D+00
% with weighted error 2.61E-17
% log weighted error 16.58
% significant figures required 15.17
% decimal places required 17.03
%
% Series for BIF2 on the interval 1.00000D+00 to 8.00000D+00
% with weighted error 1.11E-17
% log weighted error 16.95
% approx significant figures required 16.5
% decimal places required 17.45
%
% Series for BIG2 on the interval 1.00000D+00 to 8.00000D+00
% with weighted error 1.19E-18
% log weighted error 17.92
% approx significant figures required 17.2
% decimal places required 18.42
%
%***REFERENCES (NONE)
%***ROUTINES CALLED BIE, 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)
%***end PROLOGUE BI
if isempty(first), first=false; end;
if firstCall, bifcs(1)=[-.01673021647198664948e0]; end;
if firstCall, bifcs(2)=[.1025233583424944561e0]; end;
if firstCall, bifcs(3)=[.00170830925073815165e0]; end;
if firstCall, bifcs(4)=[.00001186254546774468e0]; end;
if firstCall, bifcs(5)=[.00000004493290701779e0]; end;
if firstCall, bifcs(6)=[.00000000010698207143e0]; end;
if firstCall, bifcs(7)=[.00000000000017480643e0]; end;
if firstCall, bifcs(8)=[.00000000000000020810e0]; end;
if firstCall, bifcs(9)=[.00000000000000000018e0]; end;
if firstCall, bigcs(1)=[.02246622324857452e0]; end;
if firstCall, bigcs(2)=[.03736477545301955e0]; end;
if firstCall, bigcs(3)=[.00044476218957212e0]; end;
if firstCall, bigcs(4)=[.00000247080756363e0]; end;
if firstCall, bigcs(5)=[.00000000791913533e0]; end;
if firstCall, bigcs(6)=[.00000000001649807e0]; end;
if firstCall, bigcs(7)=[.00000000000002411e0]; end;
if firstCall, bigcs(8)=[.00000000000000002e0]; end;
if firstCall, bif2cs(1)=[0.09984572693816041e0]; end;
if firstCall, bif2cs(2)=[.478624977863005538e0]; end;
if firstCall, bif2cs(3)=[.0251552119604330118e0]; end;
if firstCall, bif2cs(4)=[.0005820693885232645e0]; end;
if firstCall, bif2cs(5)=[.0000074997659644377e0]; end;
if firstCall, bif2cs(6)=[.0000000613460287034e0]; end;
if firstCall, bif2cs(7)=[.0000000003462753885e0]; end;
if firstCall, bif2cs(8)=[.0000000000014288910e0]; end;
if firstCall, bif2cs(9)=[.0000000000000044962e0]; end;
if firstCall, bif2cs(10)=[.0000000000000000111e0]; end;
if firstCall, big2cs(1)=[.033305662145514340e0]; end;
if firstCall, big2cs(2)=[.161309215123197068e0]; end;
if firstCall, big2cs(3)=[.0063190073096134286e0]; end;
if firstCall, big2cs(4)=[.0001187904568162517e0]; end;
if firstCall, big2cs(5)=[.0000013045345886200e0]; end;
if firstCall, big2cs(6)=[.0000000093741259955e0]; end;
if firstCall, big2cs(7)=[.0000000000474580188e0]; end;
if firstCall, big2cs(8)=[.0000000000001783107e0]; end;
if firstCall, big2cs(9)=[.0000000000000005167e0]; end;
if firstCall, big2cs(10)=[.0000000000000000011e0]; end;
if firstCall, first=[true]; end;
firstCall=0;
%***FIRST EXECUTABLE STATEMENT BI
if( first )
eta = 0.1.*r1mach(3);
[nbif ,bifcs,dumvar3,eta]=inits(bifcs,9,eta);
[nbig ,bigcs,dumvar3,eta]=inits(bigcs,8,eta);
[nbif2 ,bif2cs,dumvar3,eta]=inits(bif2cs,10,eta);
[nbig2 ,big2cs,dumvar3,eta]=inits(big2cs,10,eta);
%
x3sml = eta.^0.3333;
xmax =(1.5.*log(r1mach(2))).^0.6666;
end;
first = false;
%
if( x<(-1.0) )
[x,xm,theta]=r9aimp(x,xm,theta);
biresult = xm.*sin(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;
biresult = 0.625 + csevl(z,bifcs,nbif) + x.*(0.4375+csevl(z,bigcs,nbig));
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>2.0 ) ;
%
if( x>xmax )
xermsg('SLATEC','BI','X SO BIG THAT BI OVERFLOWS',1,2);
end;
%
biresult = bie(x).*exp(2.0.*x.*sqrt(x)./3.0);
else;
z =(2.0.*x.^3-9.0)./7.0;
biresult = 1.125 + csevl(z,bif2cs,nbif2)+ x.*(0.625+csevl(z,big2cs,nbig2));
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 BINOM