<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<!DOCTYPE MAN SYSTEM "../../manrev.dtd">
<MAN>
  <LANGUAGE>eng</LANGUAGE>

  <TITLE>bessel</TITLE>

  <TYPE>Scilab Function</TYPE>

  <DATE>September 1997</DATE>

  <SHORT_DESCRIPTION name="besseli">Modified Bessel function of the first kind
  (I sub alpha).</SHORT_DESCRIPTION>

  <SHORT_DESCRIPTION name="besselj">Bessel function of the first kind (J sub
  alpha).</SHORT_DESCRIPTION>

  <SHORT_DESCRIPTION name="besselk">Modified Bessel function of the second
  kind (K sub alpha).</SHORT_DESCRIPTION>

  <SHORT_DESCRIPTION name="bessely">Bessel function of the second kind (Y sub
  alpha).</SHORT_DESCRIPTION>

  <SHORT_DESCRIPTION name="besselh">Modified Bessel function of the third
  kind.</SHORT_DESCRIPTION>

  <CALLING_SEQUENCE>
    <CALLING_SEQUENCE_ITEM>y = besseli(alpha,x [,ice])</CALLING_SEQUENCE_ITEM>

    <CALLING_SEQUENCE_ITEM>y = besselj(alpha,x [,ice])</CALLING_SEQUENCE_ITEM>

    <CALLING_SEQUENCE_ITEM>y = besselk(alpha,x [,ice])</CALLING_SEQUENCE_ITEM>

    <CALLING_SEQUENCE_ITEM>y = bessely(alpha,x [,ice])</CALLING_SEQUENCE_ITEM>

    <CALLING_SEQUENCE_ITEM>y = besselh(alpha,x)</CALLING_SEQUENCE_ITEM>

    <CALLING_SEQUENCE_ITEM>y = besselh(alpha,K,x
    [,ice])</CALLING_SEQUENCE_ITEM>
  </CALLING_SEQUENCE>

  <PARAM>
    <PARAM_INDENT>
      <PARAM_ITEM>
        <PARAM_NAME>x</PARAM_NAME>

        <PARAM_DESCRIPTION>
          <SP>: real or complex vector.</SP>
        </PARAM_DESCRIPTION>
      </PARAM_ITEM>

      <PARAM_ITEM>
        <PARAM_NAME>alpha</PARAM_NAME>

        <PARAM_DESCRIPTION>
          <SP>: real vector</SP>
        </PARAM_DESCRIPTION>
      </PARAM_ITEM>

      <PARAM_ITEM>
        <PARAM_NAME>ice</PARAM_NAME>

        <PARAM_DESCRIPTION>
          <SP>: integer flag, with default value 0</SP>
        </PARAM_DESCRIPTION>
      </PARAM_ITEM>

      <PARAM_ITEM>
        <PARAM_NAME>K</PARAM_NAME>

        <PARAM_DESCRIPTION>
          <SP>: integer , with possible values 1 or 2, the Hankel function
          type.</SP>
        </PARAM_DESCRIPTION>
      </PARAM_ITEM>
    </PARAM_INDENT>
  </PARAM>

  <DESCRIPTION>
    <SP>Warning: the semantics of these function changes between Scilab-3.0
    and Scilab-3.1. The old semantics is available for compatibility using the
    oldbesseli, oldbesselj, oldbesselk, oldbessely functions.</SP>

    <DESCRIPTION_INDENT>
      <DESCRIPTION_ITEM label="*">
        <SP><VERB>besseli(alpha,x)</VERB> computes modified Bessel functions
        of the first kind (I sub alpha), for real order <VERB>alpha</VERB> and
        argument <VERB>x</VERB>. <VERB>besseli(alpha,x,1)</VERB> computes
        <VERB>besseli(alpha,x).*exp(-abs(real(x)))</VERB>.</SP>
      </DESCRIPTION_ITEM>

      <DESCRIPTION_ITEM label="*">
        <SP><VERB>besselj(alpha,x)</VERB> computes modified Bessel functions
        of the first kind (J sub alpha), for real order <VERB>alpha</VERB> and
        argument <VERB>x</VERB>. <VERB>besselj(alpha,x,1)</VERB> computes
        <VERB>besselj(alpha,x).*exp(-abs(imag(x)))</VERB>.</SP>
      </DESCRIPTION_ITEM>

      <DESCRIPTION_ITEM label="*">
        <SP><VERB>besselk(alpha,x)</VERB> computes modified Bessel functions
        of the second kind (K sub alpha), for real order <VERB>alpha</VERB>
        and argument <VERB>x</VERB>. <VERB>besselk(alpha,x,1)</VERB> computes
        <VERB>besselk(alpha,x).*exp(x)</VERB>.</SP>
      </DESCRIPTION_ITEM>

      <DESCRIPTION_ITEM label="*">
        <SP><VERB>bessely(alpha,x)</VERB> computes modified Bessel functions
        of the second kind (Y sub alpha), for real order <VERB>alpha</VERB>
        and argument <VERB>x</VERB>. <VERB>bessely(alpha,x,1)</VERB> computes
        <VERB>bessely(alpha,x).*exp(-abs(imag(x)))</VERB>.</SP>
      </DESCRIPTION_ITEM>

      <DESCRIPTION_ITEM label="*">
        <SP><VERB>besselh(alpha [,K] ,x)</VERB> computes modified Bessel
        functions of the third kind (Hankel function H1 or H2 depending on
        <VERB>K</VERB>), for real order <VERB>alpha</VERB> and argument
        <VERB>x</VERB>. If omitted <VERB>K</VERB> is supposed to be equal to
        1. <VERB>besselh(alpha,1,x,1)</VERB> computes
        <VERB>besselh(alpha,1,x).*exp(-%i*x)</VERB> and
        <VERB>besselh(alpha,2,x,1)</VERB> computes
        <VERB>besselh(alpha,2,x).*exp(%i*x)</VERB></SP>
      </DESCRIPTION_ITEM>
    </DESCRIPTION_INDENT>

    <P>If <VERB>alpha</VERB> and <VERB>x</VERB> are arrays of the same size,
    the result <VERB>y</VERB> is also that size. If either input is a scalar,
    it is expanded to the other input's size. If one input is a row vector and
    the other is a column vector, the result<VERB>y</VERB> is a
    two-dimensional table of function values.</P>

    <P>I_alpha and K_alpha are 2 independant solutions of the modified
    Bessel's differential equation :</P>

    <VERBATIM>2 2 2 x y(x)" + x y(x)' - (x + alpha ) y(x) = 0 ,</VERBATIM>

    <P>J_alpha and Y_alpha are 2 independant solutions of the Bessel's
    differential equation :</P>

    <VERBATIM>2 2 2 x y(x)" + x y(x)' + (x - alpha ) y(x) = 0 ,</VERBATIM>
  </DESCRIPTION>

  <EXAMPLE><![CDATA[
//  besselI functions
// ==================
   x = linspace(0.01,10,5000)';
   xbasc()
   subplot(2,1,1)
   plot2d(x,besseli(0:4,x), style=2:6)
   legend('I'+string(0:4),2);
   xtitle("Some modified Bessel functions of the first kind")
   subplot(2,1,2)
   plot2d(x,besseli(0:4,x,1), style=2:6)
   legend('I'+string(0:4),1);
   xtitle("Some modified scaled Bessel functions of the first kind")

// besselJ functions
// =================
   x = linspace(0,40,5000)';
   xbasc()
   plot2d(x,besselj(0:4,x), style=2:6, leg="J0@J1@J2@J3@J4")
   legend('I'+string(0:4),1);
   xtitle("Some Bessel functions of the first kind")

// use the fact that J_(1/2)(x) = sqrt(2/(x pi)) sin(x)
// to compare the algorithm of besselj(0.5,x) with a more direct formula 
   x = linspace(0.1,40,5000)';
   y1 = besselj(0.5, x);
   y2 = sqrt(2 ./(%pi*x)).*sin(x);
   er = abs((y1-y2)./y2);
   ind = find(er > 0 & y2 ~= 0);
   xbasc()
   subplot(2,1,1)
   plot2d(x,y1,style=2)
   xtitle("besselj(0.5,x)")
   subplot(2,1,2)
   plot2d(x(ind), er(ind), style=2, logflag="nl")
   xtitle("relative error between 2 formulae for besselj(0.5,x)") 

// besselK functions
// =================
   x = linspace(0.01,10,5000)';
   xbasc()
   subplot(2,1,1)
   plot2d(x,besselk(0:4,x), style=0:4, rect=[0,0,6,10])
   legend('K'+string(0:4),1);
   xtitle("Some modified Bessel functions of the second kind")
   subplot(2,1,2)
   plot2d(x,besselk(0:4,x,1), style=0:4, rect=[0,0,6,10])
   legend('K'+string(0:4),1);
   xtitle("Some modified scaled Bessel functions of the second kind")

// besselY functions
// =================
   x = linspace(0.1,40,5000)'; // Y Bessel functions are unbounded  for x -> 0+
   xbasc()
   plot2d(x,bessely(0:4,x), style=0:4, rect=[0,-1.5,40,0.6])
   legend('Y'+string(0:4),4);
   xtitle("Some Bessel functions of the second kind")

// besselH functions
// =================
   x=-4:0.025:2; y=-1.5:0.025:1.5;
   [X,Y] = ndgrid(x,y);
   H = besselh(0,1,X+%i*Y); 
   clf();f=gcf();
   xset("fpf"," ")
   f.color_map=jetcolormap(16);
   contour2d(x,y,abs(H),0.2:0.2:3.2,strf="034",rect=[-4,-1.5,3,1.5])
   legends(string(0.2:0.2:3.2),1:16,"ur")
   xtitle("Level curves of |H1(0,z)|")

  ]]></EXAMPLE>

  <AUTHORS>
    <AUTHORS_ITEM><SP>Amos, D. E., (SNLA)</SP></AUTHORS_ITEM>

    <AUTHORS_ITEM><SP>Daniel, S. L., (SNLA)</SP></AUTHORS_ITEM>
  </AUTHORS>

  <USED_FUNCTIONS>
    <SP>The source codes can be found in routines/calelm</SP>

    <P>Slatec : dbesi.f, zbesi.f, dbesj.f, zbesj.f, dbesk.f, zbesk.f, dbesy.f,
    zbesy.f, zbesh.f</P>

    <P>Drivers to extend definition area (Serge Steer INRIA): dbesig.f,
    zbesig.f, dbesjg.f, zbesjg.f, dbeskg.f, zbeskg.f, dbesyg.f, zbesyg.f,
    zbeshg.f</P>
  </USED_FUNCTIONS>
</MAN>