Solution (source code)

= Solution

Vary the gravitational volume factor and use part (a)(ii):
$$
\delta(f(R)d\operatorname{vol}_g)
=\left[f'(R)\delta R+\frac12f(R)g^{ab}h_{ab}\right]d\operatorname{vol}_g.
$$
Twice applying <integration by parts> moves both derivatives in $\delta R$ from the compactly supported $h_{ab}$ onto $f'(R)$. Combining the result with the stated matter variation and requiring every coefficient of $h_{ab}$ to vanish gives the <f(R) gravity> equation
$$
\boxed{f'(R)R_{ab}-\frac12g_{ab}f(R)
+(g_{ab}\nabla_c\nabla^c-\nabla_a\nabla_b)f'(R)
=8\pi T_{ab}}.
$$
Therefore
$$
\boxed{\alpha'=1,
\qquad\beta'=-1}.
$$