Multiple answers for the same limit expression

calculuslimits

So I was trying to find the limit of the following expression.
$$\lim_{x\to 0} \frac{\tan x – \sin x}{\sin^3 x}$$
When using the L'Hospital's rule I got the answer $\frac {1}{2}$.

My steps:
$$\lim_{x\to 0} \frac{\tan x – \sin x}{\sin^3 x} $$
$$=\lim_{x\to 0} \frac{\sec^2 x – \cos x}{3\sin^2 x \cos x}$$
$$=\lim_{x\to 0} \frac{2 \sec^2 x \tan x + \sin x}{6\sin x \cos^2 x}$$
$$=\lim_{x\to 0} \left(\frac{2 \sec^2 x \tan x}{6\sin x \cos^2 x}+\frac{\sin x}{6\sin x \cos^2 x}\right)$$
$$=\lim_{x\to 0} \left(\frac{1}{3\cos^5 x}+\frac{1}{6\cos^2 x}\right)$$
$$=\frac{1}{3}+\frac{1}{6}$$
$$=\frac{1}{2}$$

Edit: My steps are incorrect from the 3rd line onward as pointed out by @Fishbane in the comments

Just to check my answer I substituted $x = 0.000000001$ and so on, on my calculator just to be sure, but I got the result to be $0$. Believing it to be some kind of error I used WolframAlpha's calculator as well and got the same result, $0$.

What is the reason for this difference?

Best Answer

You are running into numerical error from the difference of two close numbers. For small $x, \tan x - \sin x$ is about $\frac {x^3}2$ by the Taylor series while $\tan x$ and $\sin x$ are about $x$. For $x=10^{-9}$ this is about $0.5 \cdot 10^{-27}$, which is $18$ orders of magnitude smaller than the terms you are subtracting. Due to the limited precision of computer numbers, the difference comes out $0$. Try with $x=10^{-3}$ instead and you get $\frac 12$ as you should from Alpha

Related Question