I am trying to derive $e^x \sin x - 2x \csc x$. I tried using the product and difference rule. So I got the derivative for $e^x \sin x$ and got $(e^x)(\cos(x))+(\sin(x))(e^x)$ and for the derivative of $2x \csc x $ I got $(2(x))(-\csc(x) \cot(x))+2\csc(x)$. So now I used the difference rule and simplified and what not and I ended with $(e^x)(\cos(x)+\sin(x))-2x(-\csc(x)\cot(x))+2\csc(x)$. When I entered the answer it was wrong. The answer is $(e^x)(\cos(x)+\sin(x))+2(x \cot(x)-1)\csc(x).$
I would really appreciate if someone could point out what I did wrong and how to get the correct answer, step by step preferably so I know how to deal with this issue. All help is appreciated!
The issue is merely a simplification error. By the difference rule, you must subtract the whole thing, so you get
$$ \begin{align} &e^x(\cos x + \sin x) &&- [2x(- \csc x \cot x )+ 2 \csc x]\\ = &e^x(\cos x + \sin x) && - 2x(- \csc x \cot x ) \mathbf{-} 2 \csc x\\ = &e^x(\cos x + \sin x) && + 2x( \csc x \cot x ) \mathbf{-} 2 \csc x\\ = &e^x(\cos x + \sin x) && + 2 \csc x (x \cot x \mathbf{-} 1) \end{align}$$
It's just a sign error.