function rf=ruff(xp)

pr=xp(1);
rr=xp(2);
kk=.4;
k=.4;

if rr>1
	rt=2;
	c=9.3*rr^.25;
	s=c*pr^.5;
	x0=23*rr^.33/pr^.33;
	x=x0;
	dx=1;
	dg=0.1;
	b=0;
	while abs(dx)>1e-5,
   	b=b+1;
   	se=pr/exp(x*pr/s);
   	sl=1/k/x;
   	y=exp(x*pr/s)/kk/pr;
   	dx=y-x;
   	x=x-dg*dx;
   	if mod(b,100)==0
   	   % [b x dx]
	  	end;
	end;
   rt=x/exp(kk*s*(1-1/exp(x*pr/s)));
   xu=x;
	rf=[x xu c s];
else;
   c=10;
   k=.4;
   xu=rr*exp(k*c);
   dx=1;
	dg=0.01;
   b=0;
   %solve for C and xu
   while abs(dx)>1e-4,
   	b=b+1;
      y=rr*exp(k*c*(1-exp(-xu/c)));
      dx=y-xu;
   	xu=xu-dg*dx;
   	if mod(b,100)==0
   	   % [b c xu dx]
      end; 
      c=xu/log(k*xu); 
   end;
   s=c*pr^.5;
  	x0=23*rr^.33/pr^.33;
   x=x0;
   dx=1;
	dg=0.1;
	b=0;
	while abs(dx)>1e-5,
   	b=b+1;
   	se=pr/exp(x*pr/s);
   	sl=1/k/x;
   	y=exp(x*pr/s)/kk/pr;
   	dx=y-x;
   	x=x-dg*dx;
   	if mod(b,100)==0
   	    [b x dx]
	  	end;
	end;
   rt=x/exp(kk*s*(1-1/exp(x*pr/s)));
   rf=[x xu c s];
end;