-
-
Save pgtwitter/963b2d78f0645d14188c1b8339b6b474 to your computer and use it in GitHub Desktop.
任意の数を+1する関数 ( https://www.youtube.com/watch?v=J2i24ML5hX0&t=1024s , https://www.youtube.com/watch?v=QW1wHdg3ji0&lc=UgzwbeakCr8M2YMAq4B4AaABAg )
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # %% | |
| import matplotlib.pyplot as plt | |
| import numpy as np | |
| import sympy as sym | |
| xs = np.arange(0, 10, 1E-2) | |
| xs[0] = 1E-7 | |
| x = sym.Symbol('x') | |
| def minusLn(x): | |
| return -sym.log(x) | |
| def minusExp(x): | |
| return -sym.exp(x) | |
| fig, ax = plt.subplots(figsize=(11.69, 8.27), dpi=600) | |
| ys = x | |
| for fn in [sym.sqrt, sym.atan, sym.cos, minusLn, minusLn, minusExp, sym.exp, sym.sqrt, minusLn, minusLn, sym.exp, sym.exp]: | |
| ys = fn(ys) | |
| ax.plot(xs, [ys.evalf(subs={x: v}) for v in xs], label=f'${sym.latex(ys)}$') | |
| ax.set_ylim(-4, 8) | |
| ax.set_xticks(range(11)) | |
| ax.set_yticks([x-4 for x in range(13)]) | |
| ax.grid() | |
| ax.legend(loc='lower right') | |
| ax.set_aspect('equal') |
pgtwitter
commented
Jun 2, 2026
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment