---
# System prepended metadata

title: Simple $e^x$ Implementation
tags: [e, math]

---

# Simple $e^x$ Implementation

$$
e^x \approx \sum\limits_{k=0}^\infty \frac{x^k}{k!}
$$

$$
a_k := \frac{x^k}{k!}
\implies a_k = a_{k-1} \times \frac{x}{k}\\
$$

```!javascript
function e(x, k = 10) {
    if (k == 0) return [1, 1];
    let [sum, pre] = e(x, k-1);
    let Ak = pre * x / k;
    let sum += Ak;
    return [sum, Ak];
}
```

###### tags: `math` `e`