function value = r8_besi0e ( x )

%*****************************************************************************80
%
%% R8_BESI0E evaluates the exponentially scaled Bessel function I0(X).
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    26 September 2011
%
%  Author:
%
%    Original FORTRAN77 version by Wayne Fullerton.
%    MATLAB version by John Burkardt.
%
%  Reference:
%
%    Wayne Fullerton,
%    Portable Special Function Routines,
%    in Portability of Numerical Software,
%    edited by Wayne Cowell,
%    Lecture Notes in Computer Science, Volume 57,
%    Springer 1977,
%    ISBN: 978-3-540-08446-4,
%    LC: QA297.W65.
%
%  Parameters:
%
%    Input, real X, the argument.
%
%    Output, real VALUE, the exponentially scaled Bessel function I0(X).
%
  persistent ai02cs
  persistent ai0cs
  persistent bi0cs
  persistent ntai02
  persistent ntai0
  persistent nti0
  persistent xsml

  if ( isempty ( nti0 ) )
    ai02cs = [ ...
      +0.5449041101410883160789609622680E-01, ...
      +0.3369116478255694089897856629799E-02, ...
      +0.6889758346916823984262639143011E-04, ...
      +0.2891370520834756482966924023232E-05, ...
      +0.2048918589469063741827605340931E-06, ...
      +0.2266668990498178064593277431361E-07, ...
      +0.3396232025708386345150843969523E-08, ...
      +0.4940602388224969589104824497835E-09, ...
      +0.1188914710784643834240845251963E-10, ...
      -0.3149916527963241364538648629619E-10, ...
      -0.1321581184044771311875407399267E-10, ...
      -0.1794178531506806117779435740269E-11, ...
      +0.7180124451383666233671064293469E-12, ...
      +0.3852778382742142701140898017776E-12, ...
      +0.1540086217521409826913258233397E-13, ...
      -0.4150569347287222086626899720156E-13, ...
      -0.9554846698828307648702144943125E-14, ...
      +0.3811680669352622420746055355118E-14, ...
      +0.1772560133056526383604932666758E-14, ...
      -0.3425485619677219134619247903282E-15, ...
      -0.2827623980516583484942055937594E-15, ...
      +0.3461222867697461093097062508134E-16, ...
      +0.4465621420296759999010420542843E-16, ...
      -0.4830504485944182071255254037954E-17, ...
      -0.7233180487874753954562272409245E-17, ...
      +0.9921475412173698598880460939810E-18, ...
      +0.1193650890845982085504399499242E-17, ...
      -0.2488709837150807235720544916602E-18, ...
      -0.1938426454160905928984697811326E-18, ...
      +0.6444656697373443868783019493949E-19, ...
      +0.2886051596289224326481713830734E-19, ...
      -0.1601954907174971807061671562007E-19, ...
      -0.3270815010592314720891935674859E-20, ...
      +0.3686932283826409181146007239393E-20, ...
      +0.1268297648030950153013595297109E-22, ...
      -0.7549825019377273907696366644101E-21, ...
      +0.1502133571377835349637127890534E-21, ...
      +0.1265195883509648534932087992483E-21, ...
      -0.6100998370083680708629408916002E-22, ...
      -0.1268809629260128264368720959242E-22, ...
      +0.1661016099890741457840384874905E-22, ...
      -0.1585194335765885579379705048814E-23, ...
      -0.3302645405968217800953817667556E-23, ...
      +0.1313580902839239781740396231174E-23, ...
      +0.3689040246671156793314256372804E-24, ...
      -0.4210141910461689149219782472499E-24, ...
      +0.4791954591082865780631714013730E-25, ...
      +0.8459470390221821795299717074124E-25, ...
      -0.4039800940872832493146079371810E-25, ...
      -0.6434714653650431347301008504695E-26, ...
      +0.1225743398875665990344647369905E-25, ...
      -0.2934391316025708923198798211754E-26, ...
      -0.1961311309194982926203712057289E-26, ...
      +0.1503520374822193424162299003098E-26, ...
      -0.9588720515744826552033863882069E-28, ...
      -0.3483339380817045486394411085114E-27, ...
      +0.1690903610263043673062449607256E-27, ...
      +0.1982866538735603043894001157188E-28, ...
      -0.5317498081491816214575830025284E-28, ...
      +0.1803306629888392946235014503901E-28, ...
      +0.6213093341454893175884053112422E-29, ...
      -0.7692189292772161863200728066730E-29, ...
      +0.1858252826111702542625560165963E-29, ...
      +0.1237585142281395724899271545541E-29, ...
      -0.1102259120409223803217794787792E-29, ...
      +0.1886287118039704490077874479431E-30, ...
      +0.2160196872243658913149031414060E-30, ...
      -0.1605454124919743200584465949655E-30, ...
      +0.1965352984594290603938848073318E-31 ]';
    ai0cs = [ ...
      +0.7575994494023795942729872037438E-01, ...
      +0.7591380810823345507292978733204E-02, ...
      +0.4153131338923750501863197491382E-03, ...
      +0.1070076463439073073582429702170E-04, ...
      -0.7901179979212894660750319485730E-05, ...
      -0.7826143501438752269788989806909E-06, ...
      +0.2783849942948870806381185389857E-06, ...
      +0.8252472600612027191966829133198E-08, ...
      -0.1204463945520199179054960891103E-07, ...
      +0.1559648598506076443612287527928E-08, ...
      +0.2292556367103316543477254802857E-09, ...
      -0.1191622884279064603677774234478E-09, ...
      +0.1757854916032409830218331247743E-10, ...
      +0.1128224463218900517144411356824E-11, ...
      -0.1146848625927298877729633876982E-11, ...
      +0.2715592054803662872643651921606E-12, ...
      -0.2415874666562687838442475720281E-13, ...
      -0.6084469888255125064606099639224E-14, ...
      +0.3145705077175477293708360267303E-14, ...
      -0.7172212924871187717962175059176E-15, ...
      +0.7874493403454103396083909603327E-16, ...
      +0.1004802753009462402345244571839E-16, ...
      -0.7566895365350534853428435888810E-17, ...
      +0.2150380106876119887812051287845E-17, ...
      -0.3754858341830874429151584452608E-18, ...
      +0.2354065842226992576900757105322E-19, ...
      +0.1114667612047928530226373355110E-19, ...
      -0.5398891884396990378696779322709E-20, ...
      +0.1439598792240752677042858404522E-20, ...
      -0.2591916360111093406460818401962E-21, ...
      +0.2238133183998583907434092298240E-22, ...
      +0.5250672575364771172772216831999E-23, ...
      -0.3249904138533230784173432285866E-23, ...
      +0.9924214103205037927857284710400E-24, ...
      -0.2164992254244669523146554299733E-24, ...
      +0.3233609471943594083973332991999E-25, ...
      -0.1184620207396742489824733866666E-26, ...
      -0.1281671853950498650548338687999E-26, ...
      +0.5827015182279390511605568853333E-27, ...
      -0.1668222326026109719364501503999E-27, ...
      +0.3625309510541569975700684800000E-28, ...
      -0.5733627999055713589945958399999E-29, ...
      +0.3736796722063098229642581333333E-30, ...
      +0.1602073983156851963365512533333E-30, ...
      -0.8700424864057229884522495999999E-31, ...
      +0.2741320937937481145603413333333E-31 ]';
    bi0cs = [ ...
      -0.7660547252839144951081894976243285E-01, ...
      +0.1927337953993808269952408750881196E+01, ...
      +0.2282644586920301338937029292330415, ...
      +0.1304891466707290428079334210691888E-01, ...
      +0.4344270900816487451378682681026107E-03, ...
      +0.9422657686001934663923171744118766E-05, ...
      +0.1434006289510691079962091878179957E-06, ...
      +0.1613849069661749069915419719994611E-08, ...
      +0.1396650044535669699495092708142522E-10, ...
      +0.9579451725505445344627523171893333E-13, ...
      +0.5333981859862502131015107744000000E-15, ...
      +0.2458716088437470774696785919999999E-17, ...
      +0.9535680890248770026944341333333333E-20, ...
      +0.3154382039721427336789333333333333E-22, ...
      +0.9004564101094637431466666666666666E-25, ...
      +0.2240647369123670016000000000000000E-27, ...
      +0.4903034603242837333333333333333333E-30, ...
      +0.9508172606122666666666666666666666E-33 ]';
    eta = 0.1 * r8_mach ( 3 );
    nti0 = r8_inits ( bi0cs, 18, eta );
    ntai0 = r8_inits ( ai0cs, 46, eta );
    ntai02 = r8_inits ( ai02cs, 69, eta );
    xsml = sqrt ( 8.0 * r8_mach ( 3 ) );
  end

  y = abs ( x );

  if ( y <= xsml )
    value = 1.0;
  elseif ( y <= 3.0 )
    value = exp ( - y ) * ( 2.75 ...
      + r8_csevl ( y * y / 4.5 - 1.0, bi0cs, nti0 ) );
  elseif ( y <= 8.0 )
    value = ( 0.375 + r8_csevl ( ( 48.0 / y - 11.0 ) / 5.0, ...
      ai0cs, ntai0 ) ) / sqrt ( y );
  else
    value = ( 0.375 + r8_csevl ( 16.0 / y - 1.0, ai02cs, ntai02 ) ) ...
      / sqrt ( y );
  end

  return
end
