From fde57297b3efbef28d09a532e1b3895d2b2ad917 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrik=20M=C3=BCller?= Date: Thu, 14 Jul 2022 15:03:28 +0200 Subject: Correct Makefile, add text to gamma.tex, separate python-scripts for each image --- buch/papers/laguerre/scripts/rel_error_range.py | 32 +++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 buch/papers/laguerre/scripts/rel_error_range.py (limited to 'buch/papers/laguerre/scripts/rel_error_range.py') diff --git a/buch/papers/laguerre/scripts/rel_error_range.py b/buch/papers/laguerre/scripts/rel_error_range.py new file mode 100644 index 0000000..7d017a7 --- /dev/null +++ b/buch/papers/laguerre/scripts/rel_error_range.py @@ -0,0 +1,32 @@ +if __name__ == "__main__": + import matplotlib.pyplot as plt + import numpy as np + import scipy.special + + import gamma_approx as ga + + N = 1000 + xmin = -5 + xmax = 5 + ns = np.arange(2, 12, 2) + ylim = np.array([-11, -1.2]) + + x = np.linspace(xmin + ga.EPSILON, xmax - ga.EPSILON, N) + gamma = scipy.special.gamma(x) + fig, ax = plt.subplots(num=1, clear=True, constrained_layout=True, figsize=(5, 2.5)) + for n in ns: + gamma_lag = ga.eval_laguerre_gamma(x, n=n, func="optimal_shifted") + rel_err = ga.calc_rel_error(gamma, gamma_lag) + ax.semilogy(x, np.abs(rel_err), label=f"$n={n}$") + ax.set_xlim(x[0], x[-1]) + ax.set_ylim(*(10.0 ** ylim)) + ax.set_xticks(np.arange(xmin + 1, xmax, 2)) + ax.set_xticks(np.arange(xmin, xmax), minor=True) + ax.set_yticks(10.0 ** np.arange(*ylim, 2)) + ax.set_yticks(10.0 ** np.arange(*ylim, 1), minor=True) + ax.set_xlabel(r"$z$") + # ax.set_ylabel("Relativer Fehler") + ax.legend(ncol=1, loc="upper left", fontsize=ga.fontsize) + ax.grid(1, "both") + fig.savefig(f"{ga.img_path}/rel_error_range.pgf") + # plt.show() -- cgit v1.2.1 From 3cb2fa354f814fa98474610dac744281285dafc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrik=20M=C3=BCller?= Date: Fri, 15 Jul 2022 11:40:55 +0200 Subject: First version of section 'Gauss Quadratur', fix to gamma_approx.py when z=0 --- buch/papers/laguerre/scripts/rel_error_range.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'buch/papers/laguerre/scripts/rel_error_range.py') diff --git a/buch/papers/laguerre/scripts/rel_error_range.py b/buch/papers/laguerre/scripts/rel_error_range.py index 7d017a7..7c74d76 100644 --- a/buch/papers/laguerre/scripts/rel_error_range.py +++ b/buch/papers/laguerre/scripts/rel_error_range.py @@ -5,7 +5,7 @@ if __name__ == "__main__": import gamma_approx as ga - N = 1000 + N = 1001 xmin = -5 xmax = 5 ns = np.arange(2, 12, 2) -- cgit v1.2.1 From 7a8795dcb555a551fd09a3c9b15002675e30891f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrik=20M=C3=BCller?= Date: Fri, 15 Jul 2022 16:24:48 +0200 Subject: Change image scripts to PDF format, update Makefile, add complex plane plot --- buch/papers/laguerre/scripts/rel_error_range.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'buch/papers/laguerre/scripts/rel_error_range.py') diff --git a/buch/papers/laguerre/scripts/rel_error_range.py b/buch/papers/laguerre/scripts/rel_error_range.py index 7c74d76..43b5450 100644 --- a/buch/papers/laguerre/scripts/rel_error_range.py +++ b/buch/papers/laguerre/scripts/rel_error_range.py @@ -1,13 +1,21 @@ if __name__ == "__main__": + import matplotlib as mpl import matplotlib.pyplot as plt import numpy as np import scipy.special import gamma_approx as ga - - N = 1001 - xmin = -5 - xmax = 5 + + mpl.rcParams.update( + { + "mathtext.fontset": "stix", + "font.family": "serif", + "font.serif": "TeX Gyre Termes", + } + ) + N = 1201 + xmax = 6 + xmin = -xmax ns = np.arange(2, 12, 2) ylim = np.array([-11, -1.2]) @@ -20,13 +28,14 @@ if __name__ == "__main__": ax.semilogy(x, np.abs(rel_err), label=f"$n={n}$") ax.set_xlim(x[0], x[-1]) ax.set_ylim(*(10.0 ** ylim)) - ax.set_xticks(np.arange(xmin + 1, xmax, 2)) - ax.set_xticks(np.arange(xmin, xmax), minor=True) + ax.set_xticks(np.arange(xmin, xmax + ga.EPSILON, 2)) + ax.set_xticks(np.arange(xmin, xmax + ga.EPSILON), minor=True) ax.set_yticks(10.0 ** np.arange(*ylim, 2)) - ax.set_yticks(10.0 ** np.arange(*ylim, 1), minor=True) + ax.set_yticks(10.0 ** np.arange(*ylim, 1), "", minor=True) ax.set_xlabel(r"$z$") # ax.set_ylabel("Relativer Fehler") ax.legend(ncol=1, loc="upper left", fontsize=ga.fontsize) ax.grid(1, "both") - fig.savefig(f"{ga.img_path}/rel_error_range.pgf") + # fig.savefig(f"{ga.img_path}/rel_error_range.pgf") + fig.savefig(f"{ga.img_path}/rel_error_range.pdf") # plt.show() -- cgit v1.2.1 From e1f5d6267540ea8dc758696fb08cb7540362cf8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrik=20M=C3=BCller?= Date: Mon, 18 Jul 2022 17:34:37 +0200 Subject: First complete draft of Laguerre chapter --- buch/papers/laguerre/scripts/rel_error_range.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'buch/papers/laguerre/scripts/rel_error_range.py') diff --git a/buch/papers/laguerre/scripts/rel_error_range.py b/buch/papers/laguerre/scripts/rel_error_range.py index 43b5450..ece3b6d 100644 --- a/buch/papers/laguerre/scripts/rel_error_range.py +++ b/buch/papers/laguerre/scripts/rel_error_range.py @@ -21,7 +21,7 @@ if __name__ == "__main__": x = np.linspace(xmin + ga.EPSILON, xmax - ga.EPSILON, N) gamma = scipy.special.gamma(x) - fig, ax = plt.subplots(num=1, clear=True, constrained_layout=True, figsize=(5, 2.5)) + fig, ax = plt.subplots(num=1, clear=True, constrained_layout=True, figsize=(5, 2)) for n in ns: gamma_lag = ga.eval_laguerre_gamma(x, n=n, func="optimal_shifted") rel_err = ga.calc_rel_error(gamma, gamma_lag) -- cgit v1.2.1