Ask Your Question

Revision history [back]

Can you be more specific? It's seems OK to me: with Sage 7.5.1, we have

sage: var('a b')
(a, b)
sage: f = cos(x)/(a*cos(x) + b*sin(x))
sage: F = integrate(f, x) ; F
2*a*arctan(sin(x)/(cos(x) + 1))/(a^2 + b^2) + b*log(-a - 2*b*sin(x)/(cos(x) + 1) + a*sin(x)^2/(cos(x) + 1)^2)/(a^2 + b^2) - b*log(sin(x)^2/(cos(x) + 1)^2 + 1)/(a^2 + b^2)
sage: DF = diff(F, x).simplify_full() ; DF
cos(x)/(a*cos(x) + b*sin(x))
sage: bool(DF == f)
True

Can you be more specific? It's It seems OK to me: me, since with Sage 7.5.1, we have

sage: var('a b')
(a, b)
sage: f = cos(x)/(a*cos(x) + b*sin(x))
sage: F = integrate(f, x) ; F
2*a*arctan(sin(x)/(cos(x) + 1))/(a^2 + b^2) + b*log(-a - 2*b*sin(x)/(cos(x) + 1) + a*sin(x)^2/(cos(x) + 1)^2)/(a^2 + b^2) - b*log(sin(x)^2/(cos(x) + 1)^2 + 1)/(a^2 + b^2)
sage: DF = diff(F, x).simplify_full() ; DF
cos(x)/(a*cos(x) + b*sin(x))
sage: bool(DF == f)
True

Can you be more specific? It seems OK to me, since with Sage 7.5.1, we have

sage: var('a b')
(a, b)
sage: f = cos(x)/(a*cos(x) + b*sin(x))
sage: F = integrate(f, x) ; F
2*a*arctan(sin(x)/(cos(x) + 1))/(a^2 + b^2) + b*log(-a - 2*b*sin(x)/(cos(x) + 1) + a*sin(x)^2/(cos(x) + 1)^2)/(a^2 + b^2) - b*log(sin(x)^2/(cos(x) + 1)^2 + 1)/(a^2 + b^2)
sage: DF = diff(F, x).simplify_full() ; DF
cos(x)/(a*cos(x) + b*sin(x))
sage: bool(DF == f)
True

EDIT (2 Feb 2017, after the answer/precisions posted by @bev):

To simplify further Sage's output, we may proceed as follows. First to simplify the arctan part, introduce the double-angle variable u=2*x:

sage: var('u')
u
sage: F1 = F.subs({x: 2*u}).simplify_full().trig_reduce(); F1
2*a*arctan(tan(u))/(a^2 + b^2) + b*log(-a*cos(2*u)*sec(u)^2 - b*sec(u)^2*sin(2*u))/(a^2 + b^2) - b*log(sec(u)^2)/(a^2 + b^2)

To go further, one has to assume that u in (-pi/2, pi/2), so that arctan(tan(u)) simplifies to u:

sage: assume(u>-pi/2, u<pi/2)
sage: F2 = F1.simplify_full().simplify_log().trig_reduce(); F2
2*a*u/(a^2 + b^2) + b*log(-a*cos(2*u) - b*sin(2*u))/(a^2 + b^2)

Then we can go back to the original variable and get the final result:

sage: F = F2.subs({u: x/2}).simplify_full(); F
(a*x + b*log(-a*cos(x) - b*sin(x)))/(a^2 + b^2)

which coincides with the Maple result that you've quoted, up to some sign in the log argument (which depends on the ranges of a, b and x). The obtained result is indeed correct:

sage: DF = diff(F, x).simplify_full() ; DF
cos(x)/(a*cos(x) + b*sin(x))
sage: bool(DF == f)
True