diff options
author | Patrik Müller <patrik.mueller@ost.ch> | 2022-04-06 08:00:09 +0200 |
---|---|---|
committer | Patrik Müller <patrik.mueller@ost.ch> | 2022-04-06 08:00:09 +0200 |
commit | 670555039265d83945b0d3e205aefb020425585b (patch) | |
tree | 21038cb909c97aff834de131cf0a8c5e276cb756 /buch/papers/laguerre/scripts/laguerre_plot.py | |
parent | add notes for MSE session 4 (diff) | |
download | SeminarSpezielleFunktionen-670555039265d83945b0d3e205aefb020425585b.tar.gz SeminarSpezielleFunktionen-670555039265d83945b0d3e205aefb020425585b.zip |
Start definition.tex
Diffstat (limited to 'buch/papers/laguerre/scripts/laguerre_plot.py')
-rw-r--r-- | buch/papers/laguerre/scripts/laguerre_plot.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/buch/papers/laguerre/scripts/laguerre_plot.py b/buch/papers/laguerre/scripts/laguerre_plot.py new file mode 100644 index 0000000..cd90df1 --- /dev/null +++ b/buch/papers/laguerre/scripts/laguerre_plot.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 +# -*- coding:utf-8 -*- +"""Some plots for Laguerre Polynomials.""" + +from pathlib import Path + +import matplotlib.pyplot as plt +import numpy as np +import scipy.special as ss + +N = 1000 +t = np.linspace(0, 12.5, N)[:, None] +root = str(Path(__file__).parent) + +fig, ax = plt.subplots(num=1, clear=True, constrained_layout=True, figsize=(6, 4)) +for n in np.arange(0, 10): + k = np.arange(0, n + 1)[None] + L = np.sum((-1) ** k * ss.binom(n, k) / ss.factorial(k) * t ** k, -1) + ax.plot(t, L, label=f"n={n}") +ax.set_xticks(np.arange(1, t[-1])) +ax.set_xlim(t[0], t[-1] + 0.1*(t[1] - t[0])) +ax.set_ylim(-20, 20) +ax.legend(ncol=2) +# set the x-spine +ax.spines['left'].set_position('zero') +ax.spines['right'].set_visible(False) +ax.spines['bottom'].set_position('zero') +ax.spines['top'].set_visible(False) +ax.xaxis.set_ticks_position('bottom') +ax.yaxis.set_ticks_position('left') + +# make arrows +# ax.plot((1), (0), ls="", marker=">", ms=10, color="k", +# transform=ax.get_yaxis_transform(), clip_on=False) +# ax.plot((0), (1), ls="", marker="^", ms=10, color="k", +# transform=ax.get_xaxis_transform(), clip_on=False) +# ax.grid(1) +fig.savefig(f'{root}/laguerre_polynomes.pdf') +# plt.show() |