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/targets.py | 48 +++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 buch/papers/laguerre/scripts/targets.py (limited to 'buch/papers/laguerre/scripts/targets.py') diff --git a/buch/papers/laguerre/scripts/targets.py b/buch/papers/laguerre/scripts/targets.py new file mode 100644 index 0000000..73d6e03 --- /dev/null +++ b/buch/papers/laguerre/scripts/targets.py @@ -0,0 +1,48 @@ +import numpy as np +import scipy.special + +import gamma_approx as ga + + +def find_best_loc(N=200, a=1.375, b=0.5, ns=None): + if ns is None: + ns = np.arange(2, 13) + bests = [] + step = 1 / (N - 1) + x = np.linspace(step, 1 - step, N + 1) + gamma = scipy.special.gamma(x)[:, None] + for n in ns: + zeros, weights = np.polynomial.laguerre.laggauss(n) + est = np.ceil(b + a * n) + targets = np.arange(max(est - 2, 0), est + 3) + glag = [ + ga.eval_laguerre_gamma(x, target=target, x=zeros, w=weights, func="shifted") + for target in targets + ] + gamma_lag = np.stack(glag, -1) + rel_error = np.abs(ga.calc_rel_error(gamma, gamma_lag)) + best = np.argmin(rel_error, -1) + targets[0] + bests.append(best) + return np.stack(bests, 0) + + +if __name__ == "__main__": + import matplotlib.pyplot as plt + N = 200 + ns = np.arange(2, 13) + + bests = find_best_loc(N, ns=ns) + + fig, ax = plt.subplots(num=1, clear=True, constrained_layout=True, figsize=(4, 2.4)) + v = ax.imshow(bests, cmap="inferno", aspect="auto", interpolation="nearest") + plt.colorbar(v, ax=ax, label=r"$m^*$") + ticks = np.arange(0, N + 1, N // 5) + ax.set_xlim(0, 1) + ax.set_xticks(ticks) + ax.set_xticklabels([f"{v:.2f}" for v in ticks / N]) + ax.set_xticks(np.arange(0, N + 1, N // 20), minor=True) + ax.set_yticks(np.arange(len(ns))) + ax.set_yticklabels(ns) + ax.set_xlabel(r"$z$") + ax.set_ylabel(r"$n$") + fig.savefig(f"{ga.img_path}/targets.pgf") -- 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/targets.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'buch/papers/laguerre/scripts/targets.py') diff --git a/buch/papers/laguerre/scripts/targets.py b/buch/papers/laguerre/scripts/targets.py index 73d6e03..206b3a1 100644 --- a/buch/papers/laguerre/scripts/targets.py +++ b/buch/papers/laguerre/scripts/targets.py @@ -10,24 +10,33 @@ def find_best_loc(N=200, a=1.375, b=0.5, ns=None): bests = [] step = 1 / (N - 1) x = np.linspace(step, 1 - step, N + 1) - gamma = scipy.special.gamma(x)[:, None] + gamma = scipy.special.gamma(x) for n in ns: zeros, weights = np.polynomial.laguerre.laggauss(n) est = np.ceil(b + a * n) targets = np.arange(max(est - 2, 0), est + 3) - glag = [ - ga.eval_laguerre_gamma(x, target=target, x=zeros, w=weights, func="shifted") - for target in targets - ] - gamma_lag = np.stack(glag, -1) - rel_error = np.abs(ga.calc_rel_error(gamma, gamma_lag)) + rel_error = [] + for target in targets: + gamma_lag = ga.eval_laguerre_gamma(x, target=target, x=zeros, w=weights, func="shifted") + rel_error.append(np.abs(ga.calc_rel_error(gamma, gamma_lag))) + rel_error = np.stack(rel_error, -1) best = np.argmin(rel_error, -1) + targets[0] bests.append(best) return np.stack(bests, 0) if __name__ == "__main__": + import matplotlib as mpl import matplotlib.pyplot as plt + + mpl.rcParams.update( + { + "mathtext.fontset": "stix", + "font.family": "serif", + "font.serif": "TeX Gyre Termes", + } + ) + N = 200 ns = np.arange(2, 13) @@ -45,4 +54,5 @@ if __name__ == "__main__": ax.set_yticklabels(ns) ax.set_xlabel(r"$z$") ax.set_ylabel(r"$n$") - fig.savefig(f"{ga.img_path}/targets.pgf") + # fig.savefig(f"{ga.img_path}/targets.pgf") + fig.savefig(f"{ga.img_path}/targets.pdf") -- 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/targets.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'buch/papers/laguerre/scripts/targets.py') diff --git a/buch/papers/laguerre/scripts/targets.py b/buch/papers/laguerre/scripts/targets.py index 206b3a1..3bc7f52 100644 --- a/buch/papers/laguerre/scripts/targets.py +++ b/buch/papers/laguerre/scripts/targets.py @@ -42,8 +42,8 @@ if __name__ == "__main__": bests = find_best_loc(N, ns=ns) - fig, ax = plt.subplots(num=1, clear=True, constrained_layout=True, figsize=(4, 2.4)) - v = ax.imshow(bests, cmap="inferno", aspect="auto", interpolation="nearest") + fig, ax = plt.subplots(num=1, clear=True, constrained_layout=True, figsize=(3.5, 2.1)) + v = ax.imshow(bests, cmap=ga.cmap, aspect="auto", interpolation="nearest") plt.colorbar(v, ax=ax, label=r"$m^*$") ticks = np.arange(0, N + 1, N // 5) ax.set_xlim(0, 1) -- cgit v1.2.1 From 5da2fa5a5e6a2fa2b8a23745b8c300d15a06669d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrik=20M=C3=BCller?= Date: Sat, 23 Jul 2022 15:19:20 +0200 Subject: Restruct paper, correct typos, add positive conclusion, add more citations and references, small changes to plots --- buch/papers/laguerre/scripts/targets.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'buch/papers/laguerre/scripts/targets.py') diff --git a/buch/papers/laguerre/scripts/targets.py b/buch/papers/laguerre/scripts/targets.py index 3bc7f52..69f94ba 100644 --- a/buch/papers/laguerre/scripts/targets.py +++ b/buch/papers/laguerre/scripts/targets.py @@ -38,7 +38,7 @@ if __name__ == "__main__": ) N = 200 - ns = np.arange(2, 13) + ns = np.arange(1, 13) bests = find_best_loc(N, ns=ns) -- cgit v1.2.1