One way to express
If we plot the first k terms of this series for increasing x we observe a normal distribution of the terms.
#!/usr/bin/env python | |
# coding: utf-8 | |
from __future__ import division | |
from pandas import Series | |
from math import factorial | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
def a_x(x, n): | |
return x**n / factorial(n) | |
def plot_exp_x_up_to_n(x, n=10): | |
s = Series((a_x(x, i) for i in range(n))) | |
with sns.color_palette("Greys_r"): | |
s.plot(kind='bar') | |
plt.title('terms of e(x) series for x = %d' % x) | |
plt.minorticks_off() | |
plt.xlabel('term n') | |
plt.savefig('x_%04d_n_%04d.png' % (x, n)) | |
if __name__ == '__main__': | |
for i in range(0, 40): | |
plot_exp_x_up_to_n(i, 40) |
SHELL = /bin/bash | |
images: | |
python expansion.py | |
gifs: | |
for fn in *png; do convert "$$fn" "$${fn%.png}.gif"; done | |
anim.gif: | |
gifsicle --colors 16 --delay=35 --loop x_*.gif > anim.gif | |
clean: | |
rm -f x_*_n_*.png | |
rm -f x_*_n_*.gif | |
rm -f anim.gif |