function coef = sigmoid_coef ( n )

%*****************************************************************************80
%
%% sigmoid_coef(): sigmoid derivative expansion coefficients.
%
%  Discussion:
%
%    s(x) = 1 / ( 1 + exp ( - x ) )
%
%    s(x)^(n) = sum ( 1 <= j <= n + 1 ) coef(j) * s(x)^j 
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    22 May 2024
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Joe McKenna,
%    Derivatives of the sigmoid function,
%    https://joepatmckenna.github.io/calculus/derivative/sigmoid%20function/linear%20albegra/2018/01/20/sigmoid-derivs/
%
%  Input:
%
%    integer n: the order of the derivative.
%    0 <= n.
%
%  Output:
%
%    real coef(n+2): the expansion coefficients.
%    coef(1) is always 0, and coef(2) is always 1.
%
  coef = zeros ( n + 2, 1 );

  for k = 0 : n
    cnk = 0.0;
    mop = -1.0;
    for j = 0 : k
      mop = - mop;
      cnk = cnk + mop * ( j + 1 )^n * nchoosek ( k, j );
    end
    coef(k+2,1) = cnk;
  end

  return
end

