LoginSignup
0
0

More than 5 years have passed since last update.

sympyの微分方程式で「Euler’s formula」を参考にした//本家stackoverflowの投稿を修正された

Last updated at Posted at 2018-07-11

本家stackoverflowの投稿を修正された。Answerを翻訳してみた

(参考)Solving a 4th order ODE with SymPy raises NotImplementedError: CRootOf is not supported
https://stackoverflow.com/questions/51223475/solving-a-4th-order-ode-with-sympy-raises-notimplementederror-crootof-is-not-su

私の初期投稿

sympy NotImplementedError?
diff(x,2)-->Ok,diff(x,4)-->Error
What am I doing wrong? 
Thank you in advance and sorry for the bad english! 
Euler's critical load
https://en.wikipedia.org/wiki/Euler%27s_critical_load
wolframalpha------------------------------------------------------------------------------------------------------
{w''''(x)+ă**2*w(x)''=0}
 http://www.wolframalpha.com/input/?i=%7Bw''''(x)%2B%CE%BB**2*w(x)''%3D0%7D
{w[x] == (Cos[x ă] Subscript[c, 1])/ă^2 + (Sin[x ă] Subscript[c, 2])/ă^2 + Subscript[c, 3] + x Subscript[c, 4]}
sympy--------------------------------------------------------------------------------------------------------------
full_script.py :
    from sympy import *
    x = symbols('x', real=True)
    ă = symbols('ă', real=True,positive=True)
    w = symbols('w', cls=Function)
    eq=w(x).diff(x,2) +ă**2*w(x)
    print("w=",dsolve(eq).rhs)
    eq=w(x).diff(x,4) +ă**2*w(x).diff(x,2)
    print("w=",dsolve(eq).rhs)
v= C1*sin(x*Abs(ă)) + C2*cos(x*ă)
NotImplementedError: CRootOf is not supported over ZZ[ă]

(Answerのgoogle翻訳)
SymPyで4次ODEを解決するとNotImplementedErrorが発生する:CRootOfはサポートされていない
あなたは間違って何もしていません。 NotImplementedErrorは、SymPyが解決したい式を処理できないことを意味します。この場合、問題は、多項式モジュールにあります。多項式モジュールでは、記号係数fを持つ方程式t ** 4 + f ** 2 * t ** 2 = 0で何らかの形で苦労しています。それは本当にそれを扱うことができるはずです...この特定の方程式の回避策として、記号係数?を数(例えば、7)で置き換えます。
print(dsolve(eq.subs(E、7)、w(x))。rhs.subs(7、E))
C1 + C2 * x + C3 * sin(x * f)+ C4 * cos(x * f)を出力します。
もちろん、7が他の数字と組み合わせて14などになったら、これは簡単に間違ってしまう可能性があります。しかし、それはここで動作します。

fullscript.python
from sympy import *
x = symbols('x', real=True)
w = symbols('w', cls=Function)
FE = symbols('FE', real=True,positive=True)
eq=w(x).diff(x,4) +FE**2*w(x).diff(x,2)
print("w=",dsolve(eq.subs(FE, 7), w(x)).rhs.subs(7, FE))
# w= C1 + C2*x + C3*sin(x*FE) + C4*cos(x*FE)
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