How do calculators calculate tangents?
I don't know
Maybe it is magic, you put what you want in and out pops the answer.
It is rather like pulling a rabbit out of a hat.