function fx = f4 ( x )

%*****************************************************************************80
%
%% f4() evaluates a nonlinear system of 8 equations.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    09 April 2021
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real X(N), the variable values.
%
%  Output:
%
%    real FX(N), the function values at X.
%
  n = length ( x );

  fx = zeros ( n, 1 );

  for i = 1 : n

    fx(i) = ( 3.0 - 2.0 * x(i) ) * x(i) + 1.0;

    if ( 1 < i )
      fx(i) = fx(i) - x(i-1);
    end

    if ( i < n )
      fx(i) = fx(i) - 2.0 * x(i+1);
    end

  end

  return
end
