Rational Function approximation of tan I wanted to approximate $\tan(x)$ as a rational function by capturing the zero at integer multiples of $\pi$ and poles at odd integer multiples of $\pi$. For convenience, I will be dealing with $\tan(\frac{\pi x}{2})$
$$\tan(\frac{\pi x}{2})  \approx \frac{x}{x^2-1} $$

Now I will shift and sum this approximation for every even integer (where the zeros are - truncated)

Now I will multiply it by the constant $\frac{2}{\pi}$

I check the convergence away from the origin, seems to work

My question is: What is it that I'm doing here? There seems to be some validity to it. It might be converging for the whole complex plane.
 A: In
https://en.wikipedia.org/wiki/Trigonometric_functions#Partial_fraction_expansion,
there is this:
$$\pi \tan(\pi x)
=2x\sum_{n=0}^{\infty} \dfrac1{(n+\frac12)^2-x^2}
$$
which is similar to yours.
The reference is
Aigner, Martin; Ziegler, Günter M. (2000). Proofs from THE BOOK (Second ed.). Springer-Verlag. p. 149. ISBN 978-3-642-00855-9. Archived from the original on 2014-03-08.
A little more searching
(for "partial fraction expansion of tan")
led to a proof in
https://en.wikipedia.org/wiki/Partial_fractions_in_complex_analysis
A: Note that $$\frac x{1-x^2}= \tfrac12 \left(\frac1{-1-x} + \frac1{1-x}\right).$$ Therefore your partial sums can be rewritten as $$\tfrac12 \sum_{k=0}^{2N}\left( \frac1{-(2k+1)-x} + \frac1{2k+1-x}\right) = \sum_{k=0}^{2N}\frac x{(2k+1)^2-x^2}. $$ This shows that the limit $N\to \infty$ exists for all $x$ except the odd integers since the summand is $O(k^{-2})$. Then see the answer of Marty and this wikipedia page, that shows some more identities of this nature.
A: Use the formula:
$tan(2x) = \frac{2 \times tan(x)}{1-tan^2(x)}$: 
$tan(2 \frac{\pi}{4} x) = \frac{-2 \times tan(\frac{\pi}{4} x)}{tan^2(\frac{\pi}{4} x)-1}$.
So if u use the approximation: $tan(\frac{\pi x}{4}) \approx \frac{\pi x}{4}$ (first term in Taylor series):
$tan(2 \frac{\pi}{4} x) = \frac{-2 \times (\frac{\pi}{4} x)}{(\frac{\pi}{4} x)^2-1}$.
Close to what u have written/used. It works well for $0 \leq x \leq 0.8$ but doesnt work well for $x > 0.8 $: See the plot :

A: The coefficients from other answer didn’t work for me at all. Here’s what worked.
$$f(x) = x \frac{ \frac 1{945} x^4 - \frac 1 9 x^2 + 1 } { \frac 1 {63} x^4 - \frac 4 9 x^2 + 1}$$
I have no idea where the magic numbers coming from, maple printed that in response to pade(tan(x),x,[5,4]). The approximation seems good enough for my use case.
