function [w,f] = findMin(funObj,w,maxEvals,alpha,gamma)


[f,g,H] = funObj(w); 
funEvals = 1;

while 1
	
       	alpha = 1;
	d = H\g;
	
       	wp = w - alpha*d;
	[fp,gp,Hp] = funObj(wp);
	funEvals = funEvals+1;
	
	while fp > f - gamma*alpha*g'*d
		fprintf('Backtracking...\n');
		alpha = alpha^2*g'*d/(2*(fp + g'*d*alpha - f)); 
		
      		wp = w - alpha*d;
		[fp,gp,Hp] = funObj(wp);
		funEvals = funEvals+1;
	end
	
	f_old = f;
	w = wp;
	f = fp;
	g = gp;
	H = Hp; 
	
	optCond = norm(g,'inf');
	fprintf('%6d %15.5e %15.5e %15.5e\n',funEvals,alpha,f,optCond);
	
	if optCond < 1e-2
		break;
	end
	
	if funEvals >= maxEvals
		break;
	end
end
