diff options
author | Nicolas Tobler <nicolas.tobler@ost.ch> | 2022-08-23 22:33:40 +0200 |
---|---|---|
committer | Nicolas Tobler <nicolas.tobler@ost.ch> | 2022-08-23 22:33:40 +0200 |
commit | 6ac6dd132a11abd9ec4955cd2e35e22408c982e6 (patch) | |
tree | 902445b16ec2f2b9df3b3659b6139926469c267f /buch/papers/kugel/figures/tikz/curvature-1d.py | |
parent | Added Berechnung der rationalen Funktion (diff) | |
parent | Merge pull request #63 from NaoPross/master (diff) | |
download | SeminarSpezielleFunktionen-6ac6dd132a11abd9ec4955cd2e35e22408c982e6.tar.gz SeminarSpezielleFunktionen-6ac6dd132a11abd9ec4955cd2e35e22408c982e6.zip |
Merge branch 'master' of https://github.com/AndreasFMueller/SeminarSpezielleFunktionen
Diffstat (limited to 'buch/papers/kugel/figures/tikz/curvature-1d.py')
-rw-r--r-- | buch/papers/kugel/figures/tikz/curvature-1d.py | 32 |
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") |