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?

More than 1 year has passed since last update.

√(x2-2x+2)+√(x2-6x+13)の最小値「【面白い数学クイズ】この発想、天才すぎません? 」をChatGPTとMathematicaとWolframAlphaとsympyでやってみたい。

Last updated at Posted at 2023-07-11

グラフがでます。

オリジナル(youtube) PASSLABO 様より

上と同じです。大学入試数学問題集成>テキスト
不明

(2023/07/20)

xxxx ChatGPT で(できませんでした。) xxx

最小値を求めよ。√(x2-2x+2)+√(x2-6x+13)

Mathematicaで

In:
Clear[x, f1]
Clear[x, f2]
Clear[x, f3]
f1[x_] := Sqrt[x^2 - 2*x + 2];
f2[x_] := Sqrt[x^2 - 6*x + 13];
f3[x_] := f1[x] + f2[x];
p1 = Plot[f1[x], {x, -10, 10}];
p2 = Plot[f2[x], {x, -10, 10}];
p3 = Plot[f3[x], {x, -10, 10}];
Show[p1, p2, p3]
FunctionDomain[f1[x], x]
FunctionDomain[f2[x], x]
FunctionDomain[f3[x], x]
FunctionRange[f1[x], x, y]
FunctionRange[f2[x], x, y]
FunctionRange[f3[x], x, y]

Out:
True
True
True
y >= 1
y >= 2
y >= Sqrt[13]

0.png

WolframAlphaで

グラフがでます。

sympyで( PASSLABO 様の方法を参考に)

自作関数 Poly_Pointは、他の過去問で使える気がします。
格言?「2次関数のルートは、2点間の距離かも。」
(作図省略)

from sympy import *
x=symbols('x',Real=True)
def Poly_Point(f):
    g=f**2
    a=-g.coeff(x, 1)/2
    return Point(a,sqrt(g.subs({x:a})) )
f1=sqrt(x**2-2*x+ 2)
f2=sqrt(x**2-6*x+13)
f =f1+f2
P=Point(x,0)
A=Poly_Point(f1) 
B=Poly_Point(f2) 
B=Point( B.x,B.y*(-1)*A.y/abs(A.y))
x_ans=(Line(A,B).intersection(Line(Point(0,0),Point(1,0))))[0].x
print("#",f.subs( {x:x_ans}) )
# sqrt(13)

sympyで(sympy的?安易なやり方)

minimum関数で

from sympy import *
x=symbols('x',Real=True)
f=sqrt(x**2-2*x+2)+sqrt(x**2-6*x+13)
print("#",minimum(f,x))
plot(f,0)
# sqrt(13)

微分で

from sympy import *
x=symbols('x',Real=True)
f=sqrt(x**2-2*x+2)+sqrt(x**2-6*x+13)
print("#",f.subs({x:solve(diff(f))[0]}) )
# plot(f,0)
# sqrt(13)

0png.png

sympyの実行環境

①私の環境は,pycharmです。
②よく聞くのは、Jupyterです。
③web上で、上記のソースを「SymPy Live shell」に、コピー貼り付けでもできました。
黒背景の右上に、マウスを移動すると、コピーマークが発生します。
??? タブレット環境で、コピー貼り付けが実行できませんでした。???

参考

以下、いつもの?おすすめです。

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?