function besselzero_test ( )

%*****************************************************************************80
%
%% besselzero_test() tests besselzero().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    18 March 2024
%
%  Author:
%
%    John Burkardt
%
  addpath ( '../besselzero' );

  timestamp ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'besselzero_test():\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version );
  fprintf ( 1, '  Test besselzero()\n' );

  besselzero_j_print ( );
  besselzero_j_plot ( );

  besselzero_y_print ( );
  besselzero_y_plot ( );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'besselzero_test():\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  timestamp ( );

  return
end
function besselzero_j_print ( )

%*****************************************************************************80
%
%% besselzero_j_print() tests besselzero() for the Bessel J function.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    18 March 2024
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'besselzero_j_print():\n' );
  fprintf ( 1, '  Print zeros of Bessel j function.\n' );

  n = (1:2)';
  k = 10;
  kind = 1;
  z = besselzero ( n, k, kind );

  fprintf ( 1, '\n' );
  fprintf ( 1, '    K    J0(root K)  J1(root K)\n' );
  fprintf ( 1, '\n' );
  for i = 1 : k
    fprintf ( 1, '  %2d  %g14.6  %g14.6\n', i, z(1,i), z(2,i) );
  end

  return
end
function besselzero_j_plot ( )

%*****************************************************************************80
%
%% besselzero_j_plot() tests besselzero() for the Bessel J function.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    18 March 2024
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'besselzero_j_plot():\n' );
  fprintf ( 1, '  Plot zeros of Bessel j function.\n' );

  n = (1:2)';
  k = 10;
  kind = 1;
  z = besselzero ( n, k, kind );
  x = linspace ( 0.0, z(end), 1000 );
  y = nan ( 2, length ( x ) );
  y(1,:) = besselj ( n(1), x );
  y(2,:) = besselj ( n(2), x );
  nz = nan ( size ( z ) );
  nz(1,:) = besselj ( n(1), z(1,:) );
  nz(2,:) = besselj ( n(2), z(2,:) );
  clf ( );
  hold ( 'on' );
    plot ( x, y, 'linewidth', 2 );
    plot ( z, nz, 'kx', 'markersize', 10 );
  hold ( 'off' );
  grid ( 'on' );
  title ( 'Zeros of Bessel J0(x) and J1(x)' );
  legend ( 'J0(x)', 'J1(x)' );
  filename = 'besselzero_j.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  return
end
function besselzero_y_print ( )

%*****************************************************************************80
%
%% besselzero_y_print() tests besselzero() for the Bessel Y function.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    18 March 2024
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'besselzero_y_print():\n' );
  fprintf ( 1, '  Print zeros of Bessel y function.\n' );

  n = (1:2)';
  k = 10;
  kind = 2;
  z = besselzero ( n, k, kind );

  fprintf ( 1, '\n' );
  fprintf ( 1, '    K    Y0(root K)  Y1(root K)\n' );
  fprintf ( 1, '\n' );
  for i = 1 : k
    fprintf ( 1, '  %2d  %g14.6  %g14.6\n', i, z(1,i), z(2,i) );
  end

  return
end
function besselzero_y_plot ( )

%*****************************************************************************80
%
%% besselzero_y_plot() tests besselzero() for the Bessel y function.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    18 March 2024
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'besselzero_y_plot():\n' );
  fprintf ( 1, '  Plot zeros of Bessel Y function.\n' );

  n = (1:2)';
  k = 10;
  kind = 2;
  z = besselzero ( n, k, kind );
  x = linspace ( 2.0, z(end), 1000 );
  y = nan ( 2, length ( x ) );
  y(1,:) = bessely ( n(1), x );
  y(2,:) = bessely ( n(2), x );
  nz = nan ( size ( z ) );
  nz(1,:) = bessely ( n(1), z(1,:) );
  nz(2,:) = bessely ( n(2), z(2,:) );

  clf ( );
  hold ( 'on' );
    plot ( x, y, 'linewidth', 2 );
    plot ( z, nz, 'kx', 'markersize', 10 );
  hold ( 'off' );
  grid ( 'on' );
  title ( 'Zeros of Bessel Y0(x) and Y1(x)' );
  legend ( 'Y0(x)', 'Y1(x)' );
  filename = 'besselzero_y.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  return
end
function timestamp ( )

%*****************************************************************************80
%
%% timestamp() prints the current YMDHMS date as a timestamp.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 February 2003
%
%  Author:
%
%    John Burkardt
%
  t = now;
  c = datevec ( t );
  s = datestr ( c, 0 );
  fprintf ( 1, '%s\n', s );

  return
end

