function s = arclength_t ( t1, t2, dxdt, dydt, n )

%*****************************************************************************80
%
%% arclength_t() estimates arclength for a curve of the form (x(t),y(t)).
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    12 November 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real t1, t2: the parameter range over which the curve extends.
%
%    function handle dxdt, dydt: functions which evaluate dx/dt and dy/dt.
%
%    integer n: the number of intervals to use.
%
%  Output:
%
%    real s: the estimated arclength.
%
  dt = ( t2 - t1 ) / n;

  t = linspace ( t1, t2, n + 1 );
  fx = dxdt ( t );
  fy = dydt ( t );

  s = dt * ( sum ( sqrt ( fx.^2 + fy.^2 ) ) ...
    - 0.5 * sqrt ( fx(1)^2 + fy(1)^2 ) ...
    - 0.5 * sqrt ( fx(n+1)^2 + fy(n+1)^2 ) );

  return
end

