diff options
author | LordMcFungus <mceagle117@gmail.com> | 2022-07-22 21:28:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-22 21:28:45 +0200 |
commit | 23f17598c1742c70f442b94044a20aa821022c5a (patch) | |
tree | a945540ee6a4e86b37df2f01e3a91584b4797c4f /buch/papers/laguerre/scripts/rel_error_shifted.py | |
parent | Merge pull request #2 from AndreasFMueller/master (diff) | |
parent | Merge pull request #25 from JODBaer/master (diff) | |
download | SeminarSpezielleFunktionen-23f17598c1742c70f442b94044a20aa821022c5a.tar.gz SeminarSpezielleFunktionen-23f17598c1742c70f442b94044a20aa821022c5a.zip |
Merge pull request #3 from AndreasFMueller/master
update
Diffstat (limited to 'buch/papers/laguerre/scripts/rel_error_shifted.py')
-rw-r--r-- | buch/papers/laguerre/scripts/rel_error_shifted.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/buch/papers/laguerre/scripts/rel_error_shifted.py b/buch/papers/laguerre/scripts/rel_error_shifted.py new file mode 100644 index 0000000..f53c89b --- /dev/null +++ b/buch/papers/laguerre/scripts/rel_error_shifted.py @@ -0,0 +1,40 @@ +if __name__ == "__main__": + import matplotlib as mpl + import matplotlib.pyplot as plt + import numpy as np + import scipy.special + + import gamma_approx as ga + + mpl.rcParams.update( + { + "mathtext.fontset": "stix", + "font.family": "serif", + "font.serif": "TeX Gyre Termes", + } + ) + n = 8 # order of Laguerre polynomial + N = 200 # number of points in interval + + step = 1 / (N - 1) + x = np.linspace(step, 1 - step, N + 1) + targets = np.arange(10, 14) + gamma = scipy.special.gamma(x) + fig, ax = plt.subplots(num=1, clear=True, constrained_layout=True, figsize=(5, 2.1)) + for target in targets: + gamma_lag = ga.eval_laguerre_gamma(x, target=target, n=n, func="shifted") + rel_error = np.abs(ga.calc_rel_error(gamma, gamma_lag)) + ax.semilogy(x, rel_error, label=f"$m={target}$", linewidth=3) + gamma_lgo = ga.eval_laguerre_gamma(x, n=n, func="optimal_shifted") + rel_error = np.abs(ga.calc_rel_error(gamma, gamma_lgo)) + ax.semilogy(x, rel_error, "m", linestyle=":", label="$m^*$", linewidth=3) + ax.set_xlim(x[0], x[-1]) + ax.set_ylim(5e-9, 5e-8) + ax.set_xlabel(r"$z$") + ax.set_xticks(np.linspace(0, 1, 6)) + ax.set_xticks(np.linspace(0, 1, 11), minor=True) + ax.grid(1, "both") + ax.legend(ncol=1, fontsize=ga.fontsize) + # fig.savefig(f"{ga.img_path}/rel_error_shifted.pgf") + fig.savefig(f"{ga.img_path}/rel_error_shifted.pdf") + # plt.show() |