Created
October 24, 2025 20:03
-
-
Save pokutuna/f49540c7a5736c5476e0781154b425f1 to your computer and use it in GitHub Desktop.
sample.py
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 marimo | |
| __generated_with = "0.17.1" | |
| app = marimo.App() | |
| @app.cell | |
| def _(): | |
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| print("hoge") | |
| return np, plt | |
| @app.cell | |
| def _(np, plt): | |
| # x の範囲を定義 (log(1+x) のため x > -1) | |
| x = np.linspace(0, 5, 1000) | |
| # y1 = x, y2 = x * log(1 + x) を計算 | |
| y1 = x | |
| y2 = x * np.log(1 + x) | |
| # グラフを描画 | |
| fig, ax = plt.subplots(figsize=(10, 6)) | |
| ax.plot(x, y1, label="y = x", linewidth=2) | |
| ax.plot(x, y2, label="y = x * log(1 + x)", linewidth=2) | |
| # 交点 x = e - 1 を示す | |
| x_intersect = np.e - 1 | |
| y_intersect = x_intersect | |
| ax.axvline( | |
| x_intersect, | |
| color="red", | |
| linestyle="--", | |
| alpha=0.5, | |
| label=f"x = e - 1 ≈ {x_intersect:.3f}", | |
| ) | |
| ax.plot(x_intersect, y_intersect, "ro", markersize=8) | |
| ax.set_xlabel("x") | |
| ax.set_ylabel("y") | |
| ax.set_title("x と x * log(1 + x) のグラフ") | |
| ax.legend() | |
| ax.grid(True, alpha=0.3) | |
| plt.tight_layout() | |
| fig | |
| return | |
| if __name__ == "__main__": | |
| app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment