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.

外サイクロイド「2016 東京工業大学 前期【5】」をChatGPTとWolframAlphaとsympyでやってみたい。

Last updated at Posted at 2023-10-23

・面積計算は,入試の軌跡 様のガウス・グリーンの定理を参照しました.

オリジナル
2016東京工業大学 前期【5】
入試の軌跡 様

ジャンプの調子が悪い時、(タブレットの場合)
https://math4u.site/

望星塾 様

上と同じです。大学入試数学問題集成 様>テキスト【5】

ChatGPT-3.5先生へ(???わかりませんでした。???)

次のように媒介変数表示されたxy平面上の曲線をCとする:
x=3cost-cos3t
y=3sint-sin3t
ただし0≦t≦π/2 である.
(1) dx/dtおよびdy/dtを計算し,Cの概形を図示せよ.
(2) Cとx軸とy軸で囲まれた部分の面積を求めよ.

??? 返信抜粋
>...これを計算することで、Cとx軸、y軸で囲まれた部分の面積が求められます。

sympyで教えて下さい

以下、ChatGPT-3.5先生の出力を修正できませんでした。

# ChatGPT-3.5先生の出力
from sympy import *
# from sympy import symbols, cos, sin, integrate

# 変数を定義
t = symbols('t')

# 曲線のパラメータ方程式
x = 3*cos(t) - cos(3*t)
y = 3*sin(t) - sin(3*t)

# dx/dt と dy/dt を計算
dx_dt = x.diff(t)
dy_dt = y.diff(t)

# 積分して面積を求める
area = integrate(abs(dx_dt - dy_dt), (t, 0, 0.5 * pi))

# 結果を表示
print("Cとx軸、y軸で囲まれた部分の面積: ", area.evalf())

WolframAlphaで

・グラフがでます。

・わかりませんでした。

sympyで(オリジナル 様の方法で)

勉強中。

sympyで(「2022産業医科大学医学部【3】」風で)

・面積計算は,入試の軌跡 様のガウス・グリーンの定理を参照しました.
・sympy.simplify.fu.TR9(rv)
https://docs.sympy.org/latest/modules/simplify/fu.html#sympy.simplify.fu.TR9

# ver0.1
from sympy import *
from sympy.simplify.fu import TR9
var('f,a,b',real=True,nonnegative=True)
var('θ1,θ2',real=True,nonnegative=True)
var('ω1,ω2',real=True,nonnegative=True)
var('t,Φ'  ,real=True,nonnegative=True)
(Tp,a,b,f)=(2*pi,3,1,0)
O=Point(0,0)
# ------------------------------------------------------------------
P=(Point(f,0)+Point(a*cos(θ1),a*sin(θ1)))
S=(P         +Point(b*cos(θ2),b*sin(θ2)))
# ------------------------------------------------------------------
Φ=0
rep_θt={θ1:ω1*t,θ2:ω2*t+Φ}
# ------------------------------------------------------------------
(P,S) =(P.subs(rep_θt),S.subs(rep_θt))
PS    = O.distance(P)-O.distance(S)
Φ_sol =Φ
ω1_sol=1
ω2_sol=3*ω1_sol              #角速度? 3倍
rep={ω1:ω1_sol,ω2:ω2_sol}
ff=S.x.subs(rep)
gg=S.y.subs(rep)
print("#(1)" ,TR9(diff(ff)))
print("#(1) ",TR9(diff(gg)))
print("#(2)" ,Rational(1,2)*integrate(ff*diff(gg)-diff(ff)*gg,(t,0,pi/2)))
# #########################################################################
# 図1------------------------------------------------------------------
tHani=(t,0,2*pi)
pl_Pt=plot(diff(ff),tHani,show=False,aspect_ratio=(1.0,0.5),ylim=(-8,8))
pl_St=plot(diff(gg),tHani,show=False)
pl_Pt.extend(pl_St)
pl_Pt.show()
# 図2------------------------------------------------------------------
P=(Point(f,0)+Point(a*cos(θ1),a*sin(θ1))).subs(rep_θt).subs({ω1:ω1_sol,ω2:ω2_sol,Φ:Φ_sol})
S=(P         +Point(b*cos(θ2),b*sin(θ2))).subs(rep_θt).subs({ω1:ω1_sol,ω2:ω2_sol,Φ:Φ_sol})
# (st,en)=(0,1.0)
(st,en)=(0,2*pi)
ax1=plot_parametric(P.x,P.y,(t,st,en),aspect_ratio=(1.0,1.0),
                    # line_color="blue",
                    show=False
                  )
ax2=plot_parametric(S.x,S.y,(t,st,en),
                    # line_color="blue",
                    show=False
                  )
# ------------------------------------------------------------------
def myPlotLineOPS1(tOP,O,P,S):
    var('u'  ,real=True)
    OPu=O+u*Point(P.x,P.y).subs({t:tOP})
    PSu=  1*Point(P.x,P.y).subs({t:tOP})+u*Point(S.x-P.x,S.y-P.y).subs({t:tOP})
    ay1=plot_parametric(PSu.x,PSu.y,(u,0,1),line_color="black",
                        show=False
                       )
    return ay1
def myPlotLineOPS2(tOP,O,P,S):
    var('u'  ,real=True)
    OPu=O+u*Point(P.x,P.y).subs({t:tOP})
    PSu=  1*Point(P.x,P.y).subs({t:tOP})+u*Point(S.x-P.x,S.y-P.y).subs({t:tOP})
    ay2=plot_parametric(PSu.x,PSu.y,(u,0,1),line_color="black",
                        show=False
                       )
    return ay2
def myPlotLineOPS4(tOP,O,P,S):
    var('u'  ,real=True)
    OPu=O+u*Point(P.x,P.y).subs({t:tOP})
    PSu=  1*Point(P.x,P.y).subs({t:tOP})+u*Point(S.x-P.x,S.y-P.y).subs({t:tOP})
    ay4=plot_parametric(PSu.x,PSu.y,(u,0,1),line_color="black",
                        show=False
                       )
    return ay4
def myPlotLineOPS6(tOP,O,P,S):
    var('u'  ,real=True)
    OPu=O+u*Point(P.x,P.y).subs({t:tOP})
    PSu=  1*Point(P.x,P.y).subs({t:tOP})+u*Point(S.x-P.x,S.y-P.y).subs({t:tOP})
    ay6=plot_parametric(PSu.x,PSu.y,(u,0,1),line_color="black",
                        show=False
                       )
    return ay6
ax1.extend(ax2)
ax1.extend(myPlotLineOPS1(1/8*pi,O,P,S))
ax1.extend(myPlotLineOPS2(2/8*pi,O,P,S))
ax1.extend(myPlotLineOPS4(3/8*pi,O,P,S))
ax1.extend(myPlotLineOPS6(4/8*pi,O,P,S))
ax1.show()
# 図3------------------------------------------------------------------
Pt=(O.distance(P)).subs({ω1:ω1_sol})
St=(O.distance(S)).subs({ω1:ω1_sol,ω2:ω2_sol,Φ:Φ_sol})
# tHani=(t,0,1.5)
tHani=(t,0,2*pi)
pl_Pt=plot(Pt,tHani,show=False,aspect_ratio=(1.0,1.0),ylim=(0,9))
pl_St=plot(St,tHani,show=False)
pl_Pt.extend(pl_St)
pl_Pt.show()

#(1) -6*sin(2*t)*cos(t)
#(1)  6*cos(t)*cos(2*t)
#(2) 3*pi

図1

・点P?が 1周(0≦t≦2*π) dx_dt,dy_dt
増減表作成アプリを勉強中。

0png.png

図2

・点P?が 1周(0≦t≦2*π) 平面図軌跡

1png.png

図3

・点P?が 1周(0≦t≦2*π) 原点からの距離

2png.png

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

(テンプレート)

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

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?