This is a nice example of a problem showing the interplay between mathematics and a CAS tool moderated by the user.
Appoach 1:
Simplify the integrand before integrating, and then integrate to find an obvious real result:
In[120]:= f[x_] := 1/(Sqrt[2] + Cos[4 x] + Sin[4 x])
In[123]:= g[x_] := 1/Sqrt[2] 1/(1 + Cos[4 x - \[Pi]/4])
In[124]:= f[x] == g[x] // Simplify
Out[124]= True
In[125]:= h[x_] = Integrate[g[x], x]
Out[125]= -(Tan[\[Pi]/8 - 2 x]/(4 Sqrt[2]))
Approach 2:
Find the antidrivative a[x]
by integrating, as you have done. Then plot the real and imaginary part of that antiderivative, notice that the imaginary part seems to be constant, and finally find an equvalent antiderivative a1[x]
by adding an appropriate constant as which we chose -a[0]
.
In[126]:= a[x_] = Integrate[1/(Sqrt[2] + Cos[4 x] + Sin[4 x]), x]
Out[126]= (-((1 + 3 I) + Sqrt[2]) Cos[
2 x] + ((1 + I) - I Sqrt[2]) Sin[2 x])/(
4 ((1 + I) + Sqrt[2]) Cos[2 x] + 4 I ((-1 - I) + Sqrt[2]) Sin[2 x])
In[128]:= a1[x_] = a[x] - a[0] // Simplify
Out[128]= Sin[2 x]/(2 ((1 + Sqrt[2]) Cos[2 x] + Sin[2 x]))
This quantity is a real antiderivative, and this also confirms that the imaginary part was really constant.
See that the results are equvalent
In[145]:= a1'[x] == h'[x] // FullSimplify
Out[145]= True