0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

三重積分「立方体の体積を計算するために、3重積分のmathjaxと立方体の領域を定義するmathjaxのコードを教えて下さい。」をAI先生に聞きました。

Last updated at Posted at 2025-05-13

(本日の)ChatGPT先生へ(1回目)

質問リスト

# 質問リスト
1. 立方体の体積を計算するために、3重積分のmathjaxと立方体の領域を定義するmathjaxのコードを教えて下さい。
2. 上記の3重積分の過程をsympyのソースコードで教えて下さい。
3. 四角錐についても、3重積分を使ったsympyのソースコードで教えて下さい。

(以下回答抜粋)

V = \iiint\limits_{0 \leq x \leq a,\ 0 \leq y \leq a,\ 0 \leq z \leq a} 1\ \mathrm{d}z\,\mathrm{d}y\,\mathrm{d}x
V = \int_0^a \int_0^a \int_0^a 1\ \mathrm{d}z\,\mathrm{d}y\,\mathrm{d}x
import sympy as sp

# 変数の定義
x, y, z = sp.symbols('x y z')
a = sp.Symbol('a', positive=True)  # aは正の定数とする

# 積分の設定:積分する関数は1(体積を表す)
integrand = 1

# zについて積分(内側)
int_z = sp.integrate(integrand, (z, 0, a))

# yについて積分(中間)
int_y = sp.integrate(int_z, (y, 0, a))

# xについて積分(外側)
int_x = sp.integrate(int_y, (x, 0, a))

# 結果を表示
print("立方体の体積 =", int_x)

出力結果:

立方体の体積 = a**3
import sympy as sp

# 記号の定義
x, y, z = sp.symbols('x y z')
a, h = sp.symbols('a h', positive=True)

# xとyの積分範囲(zに依存)
x_min = -(a / 2) * (h - z) / h
x_max =  (a / 2) * (h - z) / h
y_min = -(a / 2) * (h - z) / h
y_max =  (a / 2) * (h - z) / h

# 積分
volume = sp.integrate(
    1,
    (z, 0, h),
    (y, y_min, y_max),
    (x, x_min, x_max)
)

# 結果表示
print("四角錐の体積 =", volume)

出力結果:

四角錐の体積 = a**2*h/3

・以下省略

Gemini先生へ

copilot先生へ

いつもの? sympyの実行環境と 参考のおすすめです。

(テンプレート)

いつもと違うおすすめです。

wikipedia内

Qiita内

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?