function [nu, mu, nparticles, fiterr] = Get_FF_from_Bp(Bp)

%setting options for fmisearch
opts=optimset('fminsearch');      
opts=optimset(opts,'MaxIter',4000000); 
opts=optimset(opts,'MaxFunEvals',2000000);%usually 100*number of params
opts=optimset(opts,'Display','iter');
opts=optimset(opts,'TolFun',1e-9);
opts=optimset(opts,'TolX',1e-9);
%opts=optimset('LevenbergMarquardt','on');

    % guess for paramters 
    nu0 = 0.00;

    % minimization routine a la Nelder Mead
    [nu, fiterr] = fminsearch(@fit_function, nu0, opts, Bp);

    mu = 3-2*nu; %from eq(2)/Mobley et al.(2002)
    delta90 = 2/(3*(0.01-0.3084*nu)^2); %from eq(8)/Mobley et al.(2002)
    nparticles = 1+sqrt(2/(3*delta90)); %from eq(2)/Mobley et al.(2002)
        		
    disp(['nu=' num2str(nu) ' mu=' num2str(mu)  ' nparticles=' ...
          num2str(nparticles) ' err=' num2str(fiterr) ]);

      
return 

function err = fit_function(nu, Bp);

    nparticles = 1+abs(0.01-0.3084*nu);
    if (nparticles<1);
        err=1e10;
    else;    
    delta90 = 2/(3*(0.01-0.3084*nu)^2); %from eq(8)/Mobley et al.(2002)
	cphat = 1-(1-delta90^(nu+1)-0.5*(1-delta90^nu))/((1-delta90)* ...
            delta90^nu); %from eq(3)/Mobley et al.(2002)

    err = abs(Bp-cphat); %absolute error
    end;
   
    
return