Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

FredericC's answer is valid ; it just express the results in terms of sympyobjects with (currently) no automatic sage translation. A solution can be obtained in sage terms by simple transformations :

var("x, t, k")
assume(k, "integer")
Ex=tan(x)+tan(2*x)+tan(3*x)

This expression is a rational fraction in $\tan x$, which we re-express as a rational fraction in $t$ :

sage: ExT
2*(2*t^2 - 1)*(t^2 - 3)*t/((3*t^2 - 1)*(t + 1)*(t - 1))
ExT=Ex.trig_expand().factor().subs(tan(x)==t)

The roots of this fraction are the roots of its numerator...

MR=[u[0].radical_expression()
    for u in ExT.numerator().roots(x==t, ring=QQbar)]

... provided that none of these roots nullifies the denominator :

sage: any([ExT.denominator().subs(t==u).is_zero() for u in MR])
False

The properties of $\tan$ ensure us that if $x$ is a solution, so is $x+k\pi,\, k\in\mathbb{Z}$. Similarly, it is easy to check that if $x$ is a solution, so is $\pi-x$.

Sol=union([k*pi+arctan(u) for u in MR],[k*pi-arctan(u) for u in MR])
sage: Sol
[-1/3*pi + pi*k,
 pi*k,
 pi*k - arctan(1/2*sqrt(2)),
 1/3*pi + pi*k,
 pi*k + arctan(1/2*sqrt(2))]

FWIW, Mathematica proposes (using only the $2\pi$ periodicity of $\tan$, not $\pi$...) :

sage: mathematica.Solve(Ex==0,x)
{{x -> ConditionalExpression[2*Pi*C[1], Element[C[1], Integers]]}, 
 {x -> ConditionalExpression[(-2*Pi)/3 + 2*Pi*C[1], 
    Element[C[1], Integers]]}, 
 {x -> ConditionalExpression[-Pi/3 + 2*Pi*C[1], Element[C[1], Integers]]}, 
 {x -> ConditionalExpression[Pi/3 + 2*Pi*C[1], Element[C[1], Integers]]}, 
 {x -> ConditionalExpression[(2*Pi)/3 + 2*Pi*C[1], Element[C[1], Integers]]}, 
 {x -> ConditionalExpression[Pi + 2*Pi*C[1], Element[C[1], Integers]]}, 
 {x -> ConditionalExpression[-ArcTan[1/Sqrt[2]] + 2*Pi*C[1], 
    Element[C[1], Integers]]}, 
 {x -> ConditionalExpression[Pi - ArcTan[1/Sqrt[2]] + 2*Pi*C[1], 
    Element[C[1], Integers]]}, 
 {x -> ConditionalExpression[ArcTan[1/Sqrt[2]] + 2*Pi*C[1], 
    Element[C[1], Integers]]}, 
 {x -> ConditionalExpression[-Pi + ArcTan[1/Sqrt[2]] + 2*Pi*C[1], 
    Element[C[1], Integers]]}}

HTH,