function value = runge_power_series ( x, n )

%*****************************************************************************80
%
%% runge_power_series() evaluates a power series for the Runge function.
%
%  Discussion:
%
%    The Runge function considered here has the form
%      f(x) = 1 / ( 1 + 25x^2 )
%
%    The power series is 1 - (5x)^2 + (5x)^4 - (5x)^6 + (5x)^8 - (5x)^10 ...
%
%    The power series is only well defined in the open interval 
%      -1/5 < x < 1/5
%    where successive terms gradually go to zero.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    24 March 2025
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real x: the argument of the function.
%
%    integer n: the number of terms to be computed.
%
%  Output:
%
%    real value: the value of the function.
%
  value = 0.0;
  term = 1.0;
  for i = 1 : n
    value = value + term;
    term = - term .* ( 5.0 * x ).^2;
  end

  return
end
