Year 12 Maths - Calculus Question - I only got 1 part of the solution and I could not figure out how they got the other part I have done the working out for the following question:
(the question)

(my working out)

However, the solution provided by the textbook has component answers, one for x<1/2 and one for x>1/2. I am really puzzled as how to get that. When I "tan" both sides, I believe I don't need to consider any conditions when doing that (Do I have to put any conditions?) Hence how do they get two separate answers? Could someone please enlighten this for me? Thank you so much for helping! 

 A: A general rule is 
$(i). \tan^{-1}(a)+\tan^{-1}(b)=\tan^{-1}{\dfrac{a+b}{1-ab}}$ ,when $ab<1$
$(ii). \tan^{-1}(a)+\tan^{-1}(b)=\tan^{-1}{\dfrac{a+b}{1-ab}}+\pi$ , when $ab>1$
$(iii). \tan^{-1}(a)+\tan^{-1}(b)=\pi/2$, when $ab=1$
In case $(ii)$, since $ab>1$, you get a negative number in the denominator, but you cannot get a negative angle by adding two positive angles, thus the $+\pi$.
In your last step, you need to consider this. If $x>1/2$, the $2x>1$ and 
$\tan^{-1}(2)+\tan^{-1}(x)=\tan^{-1} {\dfrac{2+x}{1-2x}}+\pi$
Or, $\tan^{-1}{\dfrac{2+x}{1-2x}}=\tan^{-1}(2)+\tan^{-1}(x)-\pi$
A: Yes, you need to consider different conditions because, if $x=\frac{1}{2}$, then the denominator at $1-2x$ would be $0$ which is of course is invalid as the fraction is then undefined.
A: $\tan A=\tan B\Rightarrow A=B+n\pi(n\in\mathbb{Z})$, the function $f(x)=\arctan \frac{x+2}{1-2x}$ is discontinuous at $x=\frac{1}{2}$.
Let $x\to\frac{1}{2}^+$, then $f(x)\to-\frac{\pi}{2}$, which coincides with $\arctan \frac{1}{2}+\arctan 2 -\pi$. 
Let $x\to\frac{1}{2}^-$, then $f(x)\to\frac{\pi}{2}$, which coincides with $\arctan \frac{1}{2}+\arctan 2 $.
A: First, there's a much easier way to reach A = arctan(2). There's a trig double angle identity that states tan(a + b) = (tan(a) + tan(b))/(1 - tan(a)tan(b)). Rearranging, you get a + b = arctan(LHS). Conveniently, we see that tan(b) = 2 given how the problem is structured.
As for why the answer is piecewise, note that the quantity inside the arctan changes sign when x crosses 1/2. Since the arctan function has a range from -pi to pi, there is a "jump" as the output wraps around to fall in the correct range. The reason your work is technically faulty is because after the step tan(A) = 2, A = arctan(2) + n*pi. By initially taking the tan of both sides in step one, then taking inverse tan, you need to consider all possible values.
If you graph it in Desmos, you'll see when I mean by the "jump."
Desmos graph image
