A nice one, indeed. Here, Sage seems to use Maxima’s integrator :
sage: table([[u,(f(x)-g(x)).integrate(x,algorithm=u)] for u in ["maxima", "sympy", "giac", "fricas", "mathematica_free"]], header_row=["Algorithm", "Indefinite integral"])
Algorithm Indefinite integral
+------------------+--------------------------------------------------------------------------------------------------------------------------------------+
maxima -1/9*(-3*I*x - 1)*cos(3*x) - 1/9*(3*I*x + 1)*e^(-3*I*x) + 1/9*(3*x - I)*sin(3*x) - 1/12*cos(6*x) + 1/12*e^(-6*I*x) + 1/12*I*sin(6*x)
sympy 0
giac 0
fricas 0
mathematica_free 0
Note that :
sage: (f(x)-g(x)).integrate(x).simplify()
-1/9*(-3*I*x - 1)*cos(3*x) - 1/9*(3*I*x + 1)*e^(-3*I*x) + 1/9*(3*x - I)*sin(3*x) - 1/12*cos(6*x) + 1/12*e^(-6*I*x) + 1/12*I*sin(6*x)
but :
sage: (f(x)-g(x)).integrate(x).simplify_full()
0
and :
sage: (f(x)-g(x)).expand()
0
There are already some reports of incorrect/surprising Maxima definite and indefinite integral errors, often related to choice of branchs or branch cuts not accounted for. Would you care to check them and file a ticket if yours isn’t already known?