<s>[INST] Dual Numbers and Automatic Differentiation I have the following equation. I would like to solve this at the point x = a, but using dual numbers. 
$$f\left(x\right) = \dfrac{1}{x} + \sin\left(\dfrac{1}{x}\right)$$
Now, the derivative of this function is below, and that is the function we'd like to reach in our answer. 
$$-\dfrac{1}{x^2} - \dfrac{\cos\left(\dfrac{1}{x}\right)}{x^2}$$
Here is what I have tried, and I am finding it difficult to simplify beyond that.
$$\begin{align} f\left(x\right) = \dfrac{1}{x} + \sin\left(\dfrac{1}{x}\right)\\
&= \frac{1}{a^{\prime}+1\epsilon}+ sin(\dfrac{1}{a+1\epsilon})\\ &= \frac{a-1\epsilon}{(a-1\epsilon)(a+1\epsilon)} + sin(\frac{a-1\epsilon}{(a-1\epsilon)(a+1\epsilon)} )\end{align}$$
I do this using the following identities:


*

*$$\sin\left(\alpha + \beta \epsilon\right) = \sin\left(\alpha\right) + \cos\left(\alpha\right)\beta\epsilon$$

*$$\dfrac{1}{\alpha + \beta\epsilon} = \dfrac{\alpha - \beta\epsilon}{\left(\alpha + \beta\epsilon\right)\left(\alpha - \beta\epsilon\right)}.$$
However, I am not certain how to simplify beyond that painfully obvious first step. Any hints?
 [/INST] Break your problem into steps. Let's say $f(x) = g(x) + h(x)$ then $f' = g' + h'$ (omitting $x$). In general even with dual variables you should use the chain rule.
First solve the derivative of $1/x$ at $x=a$.
$$\begin{align} \frac{1}{a + \epsilon}  = \frac{1}{a} \frac{1}{1+ \epsilon/a} = \frac{1}{a} \big(1 - \frac{\epsilon}{a} + O(\epsilon^2) \big)\end{align}.$$ The $O(\epsilon^2)$ terms become zero. so you get $-1/a^2$
Next find the derivative of $sin(y)$. $\sin(y+\epsilon) = \sin(y)+cos(y)\epsilon\ $ so the derivative of $\sin(y)$ is $\cos(y)$. Now put $y=1/x$, and use chain rule.
</s>