Verified Answer :

\(\displaystyle\int\frac{\cos x+3\sin x+7}{\cos x+\sin x+1}\,\mathrm dx=\int\mathrm dx+2\int\frac{\sin x+3}{\cos x+\sin x+1}\,\mathrm dx\)

For the remaining integral, let \(t=\tan\dfrac x2\). Then

\(\sin x=\sin\left(2\times\dfrac x2\right)=2\sin\dfrac x2\cos\dfrac x2=\dfrac{2t}{1+t^2}\)
\(\cos x=\cos\left(2\times\dfrac x2\right)=\cos^2\dfrac x2-\sin^2\dfrac x2=\dfrac{1-t^2}{1+t^2}\)

and

\(\mathrm dt=\dfrac12\sec^2\dfrac x2\,\mathrm dx\implies \mathrm dx=2\cos^2\dfrac x2\,\mathrm dt=\dfrac2{1+t^2}\,\mathrm dt\)

Now the integral is

\(\displaystyle\int\mathrm dx+2\int\frac{\dfrac{2t}{1+t^2}+3}{\dfrac{1-t^2}{1+t^2}+\dfrac{2t}{1+t^2}+1}\times\frac2{1+t^2}\,\mathrm dt\)

The first integral is trivial, so we'll focus on the latter one. You have

\(\displaystyle2\int\frac{2t+3(1+t^2)}{(1-t^2+2t+1+t^2)(1+t^2)}\,\mathrm dt=2\int\frac{3t^2+2t+3}{(1+t)(1+t^2)}\,\mathrm dt\)

Decompose the integrand into partial fractions:

\(\dfrac{3t^2+2t+3}{(1+t)(1+t^2)}=\dfrac2{1+t}+\dfrac{1+t}{1+t^2}\)

so you have

\(\displaystyle2\int\frac{3t^2+2t+3}{(1+t)(1+t^2)}\,\mathrm dt=4\int\frac{\mathrm dt}{1+t}+2\int\frac{\mathrm dt}{1+t^2}+\int\frac{2t}{1+t^2}\,\mathrm dt\)

which are all standard integrals. You end up with

\(\displaystyle\int\mathrm dx+4\int\frac{\mathrm dt}{1+t}+2\int\frac{\mathrm dt}{1+t^2}+\int\frac{2t}{1+t^2}\,\mathrm dt\)
\(=x+4\ln|1+t|+2\arctan t+\ln(1+t^2)+C\)
\(=x+4\ln\left|1+\tan\dfrac x2\right|+2\arctan\left(\arctan\dfrac x2\right)+\ln\left(1+\tan^2\dfrac x2\right)+C\)
\(=2x+4\ln\left|1+\tan\dfrac x2\right|+\ln\left(\sec^2\dfrac x2\right)+C\)

To try to get the terms to match up with the available answers, let's add and subtract \(\ln\left|1+\tan\dfrac x2\right|\) to get

\(2x+5\ln\left|1+\tan\dfrac x2\right|+\ln\left(\sec^2\dfrac x2\right)-\ln\left|1+\tan\dfrac x2\right|+C\)
\(2x+5\ln\left|1+\tan\dfrac x2\right|+\ln\left|\dfrac{\sec^2\dfrac x2}{1+\tan\dfrac x2}\right|+C\)

which suggests A may be the answer. To make sure this is the case, show that

\(\dfrac{\sec^2\dfrac x2}{1+\tan\dfrac x2}=\sin x+\cos x+1\)

You have

\(\dfrac{\sec^2\dfrac x2}{1+\tan\dfrac x2}=\dfrac1{\cos^2\dfrac x2+\sin\dfrac x2\cos\dfrac x2}\)
\(\dfrac{\sec^2\dfrac x2}{1+\tan\dfrac x2}=\dfrac1{\dfrac{1+\cos x}2+\dfrac{\sin x}2}\)
\(\dfrac{\sec^2\dfrac x2}{1+\tan\dfrac x2}=\dfrac2{\cos x+\sin x+1}\)

So in the corresponding term of the antiderivative, you get

\(\ln\left|\dfrac{\sec^2\dfrac x2}{1+\tan\dfrac x2}\right|=\ln\left|\dfrac2{\cos x+\sin x+1}\right|\)
\(=\ln2-\ln|\cos x+\sin x+1|\)

The \(\ln2\) term gets absorbed into the general constant, and so the antiderivative is indeed given by A,

\(\displaystyle\int\frac{\cos x+3\sin x+7}{\cos x+\sin x+1}\,\mathrm dx=2x+5\ln\left|1+\tan\dfrac x2\right|-\ln|\cos x+\sin x+1|+C\)