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_shifted.py | 31 +++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 buch/papers/laguerre/scripts/rel_error_shifted.py (limited to 'buch/papers/laguerre/scripts/rel_error_shifted.py') 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..1515c6e --- /dev/null +++ b/buch/papers/laguerre/scripts/rel_error_shifted.py @@ -0,0 +1,31 @@ +if __name__ == "__main__": + import matplotlib.pyplot as plt + import numpy as np + import scipy.special + + import gamma_approx as ga + + 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.5)) + 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="dotted", 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") + # plt.show() -- 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_shifted.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'buch/papers/laguerre/scripts/rel_error_shifted.py') diff --git a/buch/papers/laguerre/scripts/rel_error_shifted.py b/buch/papers/laguerre/scripts/rel_error_shifted.py index 1515c6e..dc9d177 100644 --- a/buch/papers/laguerre/scripts/rel_error_shifted.py +++ b/buch/papers/laguerre/scripts/rel_error_shifted.py @@ -1,10 +1,18 @@ 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 @@ -19,7 +27,7 @@ if __name__ == "__main__": 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="dotted", label="$m^*$", linewidth=3) + 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$") @@ -27,5 +35,6 @@ if __name__ == "__main__": 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.pgf") + fig.savefig(f"{ga.img_path}/rel_error_shifted.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_shifted.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'buch/papers/laguerre/scripts/rel_error_shifted.py') diff --git a/buch/papers/laguerre/scripts/rel_error_shifted.py b/buch/papers/laguerre/scripts/rel_error_shifted.py index dc9d177..f53c89b 100644 --- a/buch/papers/laguerre/scripts/rel_error_shifted.py +++ b/buch/papers/laguerre/scripts/rel_error_shifted.py @@ -20,7 +20,7 @@ if __name__ == "__main__": 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.5)) + 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)) -- cgit v1.2.1