function fx = p24_fx ( n, x )

%*****************************************************************************80
%
%% p24_fx() evaluates the function for problem 24.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    01 August 2026
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    John D Cook,
%    Solving the RK4 Design Equations,
%    https://www.johndcook.com/blog/2026/07/31/runge-kutta-design/
%    Posted 31 July 2026.
%
%    Hairer, Norsett, Wanner,
%    Solving Ordinary Differential Equations I: Nonstiff Problems
%    Springer Verlag, 1987.
%
%  Input:
%
%    integer n: the number of variables and equations.
%
%    real x(n): the evaluation point.
%
%  Output:
%
%    real fx(n): the function value.
%
  fx = zeros ( n, 1 );

  a32 = x(1);
  a42 = x(2); 
  a43 = x(3);
  b1  = x(4);
  b2  = x(5);
  b3  = x(6);
  b4  = x(7);
  c2  = x(8);
  c3  = x(9);
  c4  = x(10);
  
  fx(1)  = b1 + b2 + b3 + b4 - 1.0;
  fx(2)  = b2 * c2 + b3 * c3 + b4 * c4 - 0.5;
  fx(3)  = b2 * c2^2 + b3 * c3^2 + b4 * c4^2 - 1.0 / 3.0;
  fx(4)  = b3 * a32 * c2 + b4 * ( a42 * c2 + a43 * c3 ) - 1.0 / 6.0;
  fx(5)  = b2 * c2^3 + b3 * c3^3 + b4 * c4^3 - 1.0 / 4.0;
  fx(6)  = b3 * c3 * a32 * c2 + b4 * c4 * ( a42 * c2 + a43 * c3 ) - 1.0 / 8.0;
  fx(7)  = b3 * a32 * c2^2 + b4 * ( a42 * c2^2 + a43 * c3^2 ) - 1.0 / 12.0;
  fx(8)  = b4 * a43 * a32 * c2 - 1.0 / 24.0;
  fx(9)  = b2 - b3;
  fx(10) = c2 - c3;

  return
end

