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?

1/x+1/y=1/144,x>=yを満たす(x,y)の個数とx+yの総和「PASSLABO様の東大模試初見を、初見でChatGPT-3.5先生に聞きました。」(その2/2)x,yは自然数です。

Last updated at Posted at 2024-06-16

やっぱり気になる。
 (その1/2)でx,yの自然数の条件がなかったからかも。
 どなたか、いい聞き方をアドバイスいただけると幸いです。

(再)オリジナル

PASSLABO 様 (0:00〜12:25) 以下は、1:20 Let's go(レッツゴー) からです。

ChatGPT-3.5先生へ(1回目)繰り返す

・???実行する毎に、結果が異なります。
 オリジナル様と同じ結果にならなくなりました。謎?
 私の聞き方が悪いかもです。

x,yは自然数です。
1/x+1/y=1/144,x>=y
を満たす(x,y)の個数と
x+yの総和を求めよ
日本語で

結果 いろいろ
・...これを実際に計算して、条件を満たす...
・他

ChatGPT-3.5先生へ(2回目)sympyで

sympyで
from sympy import symbols, Eq, solve

# 変数の定義
x, y = symbols('x y')

# 方程式の設定
equation = Eq(1/x + 1/y, 1/144)

# x >= y の条件を追加
conditions = [x >= y]

# 方程式を解く
solutions = solve((equation, *conditions), (x, y))

# 解の数と解の表示
print("解の数:", len(solutions))
print("解:")
for solution in solutions:
    print(solution)

# x + y の総和を計算
sum_x_y = sum(solution[0] + solution[1] for solution in solutions)
print("x + y の総和:", sum_x_y)

??? ValueError: can only solve for one symbol at a time

symbolsは、integerでpositiveになりませんか。

・結果は同じでした。

from sympy import symbols, Eq, solve

# 正の整数のシンボルとして定義
x = symbols('x', positive=True, integer=True)
y = symbols('y', positive=True, integer=True)

# 方程式の設定
equation = Eq(1/x + 1/y, 1/144)

# x >= y の条件を追加
conditions = [x >= y]

# 方程式を解く
solutions = solve((equation, *conditions), (x, y))

# 解の数と解の表示
print("解の数:", len(solutions))
print("解:")
for solution in solutions:
    print(solution)

# x + y の総和を計算
sum_x_y = sum(solution[0] + solution[1] for solution in solutions)
print("x + y の総和:", sum_x_y)

私は、ここまでです。お疲れ様でした。

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?