function arclength_t_test ( )

%*****************************************************************************80
%
%% arclength_t_test() tests arclength_t().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    15 November 2020
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'arclength_t_test():\n' );
  fprintf ( 1, '  arclength_t() estimates the arclength of a curve (x(t),y(t))\n' );
  fprintf ( 1, '  over a range t1 <= t <= t2 using n intervals.\n' );
%
%  Circle.
%
  t1 = 0.0;
  t2 = 2.0 * pi;
  dxdt = @ dxdt1;
  dydt = @ dydt1;
  n = 2;

  s_true = 2.0 * pi;

  fprintf ( 1, '\n' );
  fprintf ( 1, '   n    s        |error|\n' );
  fprintf ( 1, '\n' );
  for i = 1 : 5
    s = arclength_t ( t1, t2, dxdt, dydt, n );
    e = abs ( s - s_true );
    fprintf ( 1, '  %2d  %8.6f  %8.6f\n', n, s, e )
    n = n * 2;
  end
%
%  Ellipse
%
  t1 = 0.0;
  t2 = 2.0 * pi;
  dxdt = @ dxdt2;
  dydt = @ dydt2;
  n = 2;

  s_true = 69.03933778699452855;

  fprintf ( 1, '\n' );
  fprintf ( 1, '   n    s        |error|\n' );
  fprintf ( 1, '\n' );
  for i = 1 : 5
    s = arclength_t ( t1, t2, dxdt, dydt, n );
    e = abs ( s - s_true );
    fprintf ( 1, '  %2d  %8.6f  %8.6f\n', n, s, e )
    n = n * 2;
  end
%
%  Astroid
%
  t1 = 0.0;
  t2 = 2.0 * pi;
  dxdt = @ dxdt3;
  dydt = @ dydt3;
  n = 2;

  s_true = 6.0;

  fprintf ( 1, '\n' );
  fprintf ( 1, '   n    s        |error|\n' );
  fprintf ( 1, '\n' );
  for i = 1 : 10
    s = arclength_t ( t1, t2, dxdt, dydt, n );
    e = abs ( s - s_true );
    fprintf ( 1, '  %2d  %8.6f  %8.6f\n', n, s, e )
    n = n * 2;
  end
%
%  Cycloid
%
  t1 = 0.0;
  t2 = 2.0 * pi;
  dxdt = @ dxdt4;
  dydt = @ dydt4;
  n = 2;

  s_true = 8.0;

  fprintf ( 1, '\n' );
  fprintf ( 1, '   n    s        |error|\n' );
  fprintf ( 1, '\n' );
  for i = 1 : 5
    s = arclength_t ( t1, t2, dxdt, dydt, n );
    e = abs ( s - s_true );
    fprintf ( 1, '  %2d  %8.6f  %8.6f\n', n, s, e )
    n = n * 2;
  end

  return
end
function value = dxdt1 ( t )

%*****************************************************************************80
%
%% dxdt1 returns the x derivative of test function 1.
%
%  Discussion:
%
%    x(t) = cos ( t )
%    y(t) = sin ( t )
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    13 November 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real T: the argument.
%
%  Output:
%
%    real VALUE: the derivative value at T.
%
  value = - sin ( t );

  return
end

function value = dydt1 ( t )

%*****************************************************************************80
%
%% dydt1 returns the y derivative of test function 1.
%
%  Discussion:
%
%    x(t) = cos ( t )
%    y(t) = sin ( t )
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    13 November 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real T: the argument.
%
%  Output:
%
%    real VALUE: the derivative value at T.
%
  value = cos ( t );

  return
end
function value = dxdt2 ( t )

%*****************************************************************************80
%
%% dxdt2 returns the x derivative of test function 2.
%
%  Discussion:
%
%    x(t) = 15 * cos ( t )
%    y(t) = 6 * sin ( t )
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    15 November 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real T: the argument.
%
%  Output:
%
%    real VALUE: the derivative value at T.
%
  a = 15.0;
  value = - a * sin ( t );

  return
end

function value = dydt2 ( t )

%*****************************************************************************80
%
%% dydt2 returns the y derivative of test function 2.
%
%  Discussion:
%
%    x(t) = 15 cos ( t )
%    y(t) = 6 sin ( t )
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    15 November 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real T: the argument.
%
%  Output:
%
%    real VALUE: the derivative value at T.
%
  b = 6.0;
  value = b * cos ( t );

  return
end

function value = dxdt3 ( t )

%*****************************************************************************80
%
%% dxdt3 returns the x derivative of test function 3.
%
%  Discussion:
%
%    x(t) = cos^3 ( t )
%    y(t) = sin^3 ( t )
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    15 November 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real T: the argument.
%
%  Output:
%
%    real VALUE: the derivative value at T.
%
  value = - 3.0 * sin ( t ) .* ( cos ( t ) ).^2;

  return
end

function value = dydt3 ( t )

%*****************************************************************************80
%
%% dydt3 returns the y derivative of test function 3.
%
%  Discussion:
%
%    x(t) = cos^3 ( t )
%    y(t) = sin^3 ( t )
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    15 November 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real T: the argument.
%
%  Output:
%
%    real VALUE: the derivative value at T.
%
  value = 3.0 * cos ( t ) .* ( sin ( t ) ).^2;

  return
end

function value = dxdt4 ( t )

%*****************************************************************************80
%
%% dxdt4 returns the x derivative of test function 4.
%
%  Discussion:
%
%    x(t) = t - sin ( t )
%    y(t) = 1 - cos ( t )
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    15 November 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real T: the argument.
%
%  Output:
%
%    real VALUE: the derivative value at T.
%
  value = 1.0 - cos ( t );

  return
end

function value = dydt4 ( t )

%*****************************************************************************80
%
%% dydt4 returns the y derivative of test function 4.
%
%  Discussion:
%
%    x(t) = t - sin ( t )
%    y(t) = 1 - cos ( t )
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    15 November 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real T: the argument.
%
%  Output:
%
%    real VALUE: the derivative value at T.
%
  value = sin ( t );

  return
end


