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.

sinやcosの4乗や6乗「2017 青森公立大学前期 経営経済学部【1】問題3」をChatGPTとWolframAlphaとsympyでやってみたい。

Last updated at Posted at 2023-08-14

・グラフが、でます。
・youtubeを探しましたが、見当たりませんでした。残念。(2023/08/14)
・「こうすれば確実」という必勝法?の検討は、閲覧数を増やすため、後日?投稿予定です
 アドバイスいただけると、幸いです。

オリジナル 

上と同じです。大学入試数学問題集成>テキスト【1】問題3
???ジャンプの調子が悪いです。???

公式ホームページ 2017年度
なし。年度切れ 
公式ホームページ 2019年度〜2023年度入学者選抜
https://www.nebuta.ac.jp/for-examinee/about-past-problems

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

入力文

問題3 次の式を簡単にせよ.
(cosθ^2+sinθ^2)^3-(cosθ^6+sinθ^6)
(2*(cosθ^6+sinθ^6)+1)/(3*(sinθ^4 + cosθ^4))

>この式も、具体的なθの値がわからない限り簡略化できません。

WolframAlphaで

(1)できませんでした。グラフがでます。

(2)グラフがでます。

結果 1

sympyで [1]T氏の数学日記 様のやり方

勉強中。(三角関数の加法定理、倍角の公式) 覚えるのは、大変ですよね。

sympyで? [2] 部分点?狙い

(1)がわからなくても,(2)で部分点がもらえるかも。
(いつものまたかのゆうどうです。2022年、自転車君)
受験生は、試験会場で一生懸命です。

# 以下、プログラムでありません。(答案の書き方を勉強中)
# (2)の答えは、一目で 1。(2+1)/3=1 
# 偶数乗。4乗,6乗だから、角度は,0度以上45度以下だよね。
#  0度の時 (2(1^6+0^6)+1)/(3(1^4+0^4)=3/3=1
# 45度の時 y=√2/2、2(y^6+y^6)+1 と 3((y^4+y^4) (3/2)/(3/2)=1
# 2つOKだから、0度,45度...8個OKだよね。
# 答えは、1じゃないかな?

sympyで [3] 安易な解法?変数cos^2,sin^2をa,bに置き換える。

>次数を下げるというのを1つの方針とすれば,道が開けそうです。
sin(θ)^2をa,cos(θ)^2をbと置き換えれば、
a,bの3次多項式(ただし,a+b=1の条件付き)。
因数分解すれば、なんとかなりそう。いつのまにか、三角関数じゃないよね。
(2)は、分子だけ変換しています。
プログラムについて、(2)後半は、subsでなく、文字列のreplaceです。詳しい方教えて下さい。

Substitution
https://docs.sympy.org/latest/tutorials/intro-tutorial/basic_operations.html#substitution

factor() takes a polynomial and factors it into irreducible factors over the rational numbers. For example:
https://docs.sympy.org/latest/tutorials/intro-tutorial/simplification.html#factor

# (1) ####################################################################
from sympy import *
var('a,b',real=True)
var('θ'  ,real=True)
mySubs1={sin(θ)**2:a,cos(θ)**2:b}
mySubs2={a:sin(θ)**2,b:cos(θ)**2}
mySubs3={a+b:1}
f =(cos(θ)**2+sin(θ)**2)**3-(cos(θ)**6+sin(θ)**6)   ;print("#(1  )",f  )
f1=f .subs(mySubs1)                                 ;print("#(1.1)",f1 )
f2=f1.factor()                                      ;print("#(1.2)",f2 )
f3=f2.subs(mySubs3)                                 ;print("#(1.3)",f3 )
f4=f3.subs(mySubs2)                                 ;print("#(1.4)",f4 )
#(1  ) (sin(θ)**2 + cos(θ)**2)**3 - sin(θ)**6 - cos(θ)**6
#(1.1) -a**3 - b**3 + (a + b)**3
#(1.2) 3*a*b*(a + b)
#(1.3) 3*a*b
#(1.4) 3*sin(θ)**2*cos(θ)**2
# (2) ####################################################################
from sympy import *
var('a,b'      ,real=True)
var('θ'        ,real=True)
var('sinθ,cosθ',real=True)
mySubs1={sin(θ)**2:a,cos(θ)**2:b}
mySubs2={a:sinθ**2,b:cosθ**2}
mySubs3={a+b:1}
mySubs4={1:(a+b)**3}
g =(2*(cos(θ)**6+sin(θ)**6)+1)/(3*(sin(θ)**4 + cos(θ)**4))
h =numer(g)                               ;print("#(2  )",h )
h1=h .subs(mySubs1)                       ;print("#(2.1)",h1)
h2=h1.subs(mySubs4)                       ;print("#(2.2)",h2)
h3=h2.factor()                            ;print("#(2.3)",h3)
h4=h3.subs(mySubs3)                       ;print("#(2.4)",h4)
h5=h4.factor()                            ;print("#(2.5)",h5)
h6=h5.subs(mySubs2)                       ;print("#(2.6)",h6)
h7=h6.factor()                            ;print("#(2.7)",h7)
h8=str(h7)                                ;print("#(2.8)",h8)
h9=str(h8).replace("sinθ","sin(θ)")       ;print("#(2.9)",h9)
hA=str(h9).replace("cosθ","cos(θ)")       ;print("#(2.A)",hA)
#(2  ) 2*sin(θ)**6 + 2*cos(θ)**6 + 1
#(2.1) 2*a**3 + 2*b**3 + 1
#(2.2) 2*a**3 + 2*b**3 + (a + b)**3
#(2.3) 3*(a + b)*(a**2 + b**2)
#(2.4) 3*a**2 + 3*b**2
#(2.5) 3*(a**2 + b**2)
#(2.6) 3*cosθ**4 + 3*sinθ**4
#(2.7) 3*(cosθ**4 + sinθ**4)
#(2.8) 3*(cosθ**4 + sinθ**4)
#(2.9) 3*(cosθ**4 + sin(θ)**4)
#(2.A) 3*(cos(θ)**4 + sin(θ)**4)

sympyで [4] グラフもでます。

・(2)について、θだけの、茨の道へ。 
 >次数を下げるというのを1つの方針とすれば,道が開けそうです。
 分母が一項式? 分子の+1が匂いますね。
 分子が6乗だから,1=cos(θ)^2+sin(θ)^2 より 1^3=(cos(θ)^2+sin(θ)^2)^3 です。  
 ???問題文(1)を使っていません。おかしいな???  

・グラフの範囲? 〜45度、〜360度。心配になってきたので、多めにしました。

# (1)#####################################################################
from sympy import *
θ=symbols('θ',real=True)
f =(cos(θ)**2+sin(θ)**2)**3-(cos(θ)**6+sin(θ)**6)    ;print("#(1  )",f )
f1=f.expand()                                       ;print("#(1.1)",f1)
f2=f1.factor()                                      ;print("#(1.2)",f2)
f3=f2.subs({sin(θ)**2 + cos(θ)**2:1})               ;print("#(1.3)",f3)
print()
#(1  ) (sin(θ)**2 + cos(θ)**2)**3 - sin(θ)**6 - cos(θ)**6
#(1.1) 3*sin(θ)**4*cos(θ)**2 + 3*sin(θ)**2*cos(θ)**4
#(1.2) 3*(sin(θ)**2 + cos(θ)**2)*sin(θ)**2*cos(θ)**2
#(1.3) 3*sin(θ)**2*cos(θ)**2
# (2)#####################################################################
from sympy import *
θ =symbols('θ',real=True)
g =(2*(cos(θ)**6+sin(θ)**6)+1)/(3*(sin(θ)**4 + cos(θ)**4))
h =numer(g)                               ;print("#(2  )",h )
h1=h .subs({1:(sin(θ)**2+cos(θ)**2)**3})  ;print("#(2.2)",h1) 
h2=h1.expand()                            ;print("#(2.3)",h2) 
h3=h2.factor()                            ;print("#(2.4)",h3) 
h4=h3.subs({ sin(θ)**2+cos(θ)**2    :1})  ;print("#(2.5)",h4) 
h5=h4.factor()                            ;print("#(2.6)",h5) 
print()
#(2  ) 2*sin(θ)**6 + 2*cos(θ)**6 + 1
#(2.2) (sin(θ)**2 + cos(θ)**2)**3 + 2*sin(θ)**6 + 2*cos(θ)**6
#(2.3) 3*sin(θ)**6 + 3*sin(θ)**4*cos(θ)**2 + 3*sin(θ)**2*cos(θ)**4 + 3*cos(θ)**6
#(2.4) 3*(sin(θ)**2 + cos(θ)**2)*(sin(θ)**4 + cos(θ)**4)
#(2.5) 3*sin(θ)**4 + 3*cos(θ)**4
#(2.6) 3*(sin(θ)**4 + cos(θ)**4)
# (3)##################################################################=#####
plot(f,g,h, ,aspect_ratio=(1.0,1.0),xlim=(-5,5),ylim=(-2,5))
print("#(3  )", f,",",h  )
print("#(3.1)",(f-h).simplify()) 
print("#(3.2)","(-3)*(",(f-h).simplify()/(-3),")")
#(3  ) (sin(θ)**2 + cos(θ)**2)**3 - sin(θ)**6 - cos(θ)**6 , 2*sin(θ)**6 + 2*cos(θ)**6 + 1
#(3.1) -3*sin(θ)**6 - 3*cos(θ)**6
#(3.2) (-3)*( sin(θ)**6 + cos(θ)**6 )

(1)(2)のグラフ。(2)は、y=1でした。
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?