I recently learned that Madhava of Kerala (c.1340–c.1425) was the first to discover the following formula for $\pi$: $$\frac{\pi}4\ =\ 1 - \frac13+\frac15 - \frac17 + \frac19 - \frac1{11} + \cdots$$ The formula was rediscovered by James Gregory (1671) and Gottfried Leibniz (1673) and is named after both of them. But Madhava discovered not one but two formulas for $\pi$, the following converging much more quickly than the one above: $$\pi\ =\ \sqrt{12}\left(1 - \frac1{3\cdot3} +\frac1{5\cdot3^2} - \frac1{7\cdot3^3} + \cdots\right)$$ In fact we now know that $$\tan^{-1}\theta\ =\ \theta - \frac{\theta^3}3 + \frac{\theta^5}5 - \frac{\theta^7}7 + \cdots$$ and the first and second formulas can be obtained by putting $\theta=1$ and $\theta=\frac1{\sqrt3}$ respectively into the above Maclaurin series expansion of $\arctan\theta$.
What I would like to know is how Madhava discovered his formulas for $\pi$ without knowing anything about Maclaurin series. It is surely inconceivable that he knew as much calculus as Newton or Leibniz, the two men credited with the invention of calculus as a mathematical tool two and a half centuries after his death. What, then, inspired him to his discoveries?