aboutsummaryrefslogtreecommitdiffstats
path: root/buch/papers/kugel/figures/tikz/curvature-1d.py
diff options
context:
space:
mode:
authorNao Pross <np@0hm.ch>2022-08-17 16:12:40 +0200
committerNao Pross <np@0hm.ch>2022-08-17 16:12:40 +0200
commit88cc0ae20e53d67b671f0713a7921c18736bdf3e (patch)
treedff47b425f9b17d5d1ad1b2f2226c2c04b8b61a5 /buch/papers/kugel/figures/tikz/curvature-1d.py
parentkugel: Add reference (diff)
downloadSeminarSpezielleFunktionen-88cc0ae20e53d67b671f0713a7921c18736bdf3e.tar.gz
SeminarSpezielleFunktionen-88cc0ae20e53d67b671f0713a7921c18736bdf3e.zip
kugel: fix figures makefile, add curvature-1d
Diffstat (limited to 'buch/papers/kugel/figures/tikz/curvature-1d.py')
-rw-r--r--buch/papers/kugel/figures/tikz/curvature-1d.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/buch/papers/kugel/figures/tikz/curvature-1d.py b/buch/papers/kugel/figures/tikz/curvature-1d.py
new file mode 100644
index 0000000..4710fc8
--- /dev/null
+++ b/buch/papers/kugel/figures/tikz/curvature-1d.py
@@ -0,0 +1,32 @@
+import numpy as np
+import matplotlib.pyplot as plt
+
+
+@np.vectorize
+def fn(x):
+ return (x ** 2) * 2 / 100 + (1 + x / 4) + np.sin(x)
+
+@np.vectorize
+def ddfn(x):
+ return 2 * 5 / 100 - np.sin(x)
+
+x = np.linspace(0, 10, 500)
+y = fn(x)
+ddy = ddfn(x)
+
+cmap = ddy - np.min(ddy)
+cmap = cmap * 1000 / np.max(cmap)
+
+plt.plot(x, y)
+plt.plot(x, ddy)
+# plt.plot(x, cmap)
+
+plt.show()
+
+fname = "curvature-1d.dat"
+np.savetxt(fname, np.array([x, y, cmap]).T, delimiter=" ")
+
+# with open(fname, "w") as f:
+# # f.write("x y cmap\n")
+# for xv, yv, cv in zip(x, y, cmap):
+# f.write(f"{xv} {yv} {cv}\n")