function y = daub10_scale ( n, x )

%*****************************************************************************80
%
%% daub10_scale() recursively evaluates the DAUB10 scaling function.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    01 August 2011
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer N, the recursion level.
%
%    real X, the point at which the function is to be evaluated.
%
%  Output:
%
%    real Y, the estimated value of the function.
%
  c = [ ...
    0.1601023979741929; ...
    0.6038292697971895; ...
    0.7243085284377726; ...
    0.1384281459013203; ...
   -0.2422948870663823; ...
   -0.0322448695846381; ...
    0.0775714938400459; ...
   -0.0062414902127983; ...
   -0.0125807519990820; ...
    0.0033357252854738 ];

  c = c * sqrt ( 2.0 );

  if ( 0 < n )
    y =  c(1) * daub10_scale ( n - 1, 2 * x     ) ...
      +  c(2) * daub10_scale ( n - 1, 2 * x - 1 ) ...
      +  c(3) * daub10_scale ( n - 1, 2 * x - 2 ) ...
      +  c(4) * daub10_scale ( n - 1, 2 * x - 3 ) ...
      +  c(5) * daub10_scale ( n - 1, 2 * x - 4 ) ...
      +  c(6) * daub10_scale ( n - 1, 2 * x - 5 ) ...
      +  c(7) * daub10_scale ( n - 1, 2 * x - 6 ) ...
      +  c(8) * daub10_scale ( n - 1, 2 * x - 7 ) ...
      +  c(9) * daub10_scale ( n - 1, 2 * x - 8 ) ...
      + c(10) * daub10_scale ( n - 1, 2 * x - 9 );
  else
    y = ( 0 <= x && x < 1 );
  end

  return
end
