function gama_opt=computeGammaOptimalFW(X, z, a, b, GXTP, mu, nu, y, yExpected, params)

% bMy                    = cellMinus(b, y);
% params.computeGradFlag = 0;
% gama_n                 = 2 * (computefQuad(X, z, a - z, y, bMy, mu, GXTP, params) - mu * linearPartLineSearch(bMy, yExpected));
% params.computeGradFlag = 1;
% gama_d                 = (computefQuad(X, z - a, z - a, bMy, bMy, mu, GXTP, params));
% gama                   = - gama_n / (2 * gama_d);
% gama_opt               = max(min(gama, 1), 0);

bMy                    = cellMinus(b, y);
gama_n                 = 2 * (computefQuad(X, z, a - z, cellMinus(y, yExpected), bMy, mu, nu, GXTP, params));% - mu * linearPartLineSearch(bMy, yExpected));
gama_d                 = (computefQuad(X, a - z, a - z, bMy, bMy, mu, nu, GXTP, params));
gama                   = - gama_n / (2*gama_d);
gama_opt               = max(min(gama, 1), 0);

end