function [so, bo] = wpar1(F, t, N, sig0, sigmax, Ntol, bopt)

%  The function [so,bo] = wpar1(F,t,N,sig0,sigmax,Ntol,bopt) estimates 
%  the optimal parameters s (= sigma) and b for the Weeks method  
%  The code assumes that an optimal curve b = b(s) has been
%  determined a priori.
%
%  Input:
%  F -- Transform; symbolic function of s.
%  t -- Ordinate where f(t) are to be computed (scalar).
%  N -- Number of terms in the Weeks expansion.
%  sig0, sigmax -- Interval where the optimal sigma is likely to be located.
%  Ntol -- Determines the tolerance in the optimization routine fmin.
%          Large Ntol => small tolerance.  Recommended: Ntol = 20 to 50.
%  bopt -- Optimal b = b(s); symbolic function of s.
% 
%  Output:
%  (so, bo) -- Estimated parameters to be used in weeks.m or weekse.m.

tols = (sigmax-sig0)/Ntol;
options = [0 tols];
so = fmin('werr1',sig0,sigmax,options,F,t,N,bopt);
s = so; bo = eval(bopt); 

