In [1]:
import sympy as sp
sp.init_printing()

In [2]:
Uo,x,s=sp.symbols('Uo x s', real=True)

In [3]:
U=Uo*((s/x)**12-(s/x)**6)
U


Out[3]:
$\displaystyle Uo \left(\frac{s^{12}}{x^{12}} - \frac{s^{6}}{x^{6}}\right)$

In [4]:
Up=U.diff(x)
Up


Out[4]:
$\displaystyle Uo \left(- \frac{12 s^{12}}{x^{13}} + \frac{6 s^{6}}{x^{7}}\right)$

In [5]:
roots = sp.solve(Up,x)
roots


Out[5]:
$\displaystyle \left[ - \sqrt[6]{2} s, \ \sqrt[6]{2} s, \ s \left(- \frac{\sqrt[6]{2}}{2} - \frac{\sqrt[6]{2} \sqrt{3} i}{2}\right), \ s \left(- \frac{\sqrt[6]{2}}{2} + \frac{\sqrt[6]{2} \sqrt{3} i}{2}\right), \ s \left(\frac{\sqrt[6]{2}}{2} - \frac{\sqrt[6]{2} \sqrt{3} i}{2}\right), \ s \left(\frac{\sqrt[6]{2}}{2} + \frac{\sqrt[6]{2} \sqrt{3} i}{2}\right)\right]$

In [6]:
x0=roots[1]
print(x0)
x0


2**(1/6)*s
Out[6]:
$\displaystyle \sqrt[6]{2} s$

In [7]:
Um=U.subs(x,x0)
print(Um)
Um


-Uo/4
Out[7]:
$\displaystyle - \frac{Uo}{4}$

In [8]:
Upp=Up.diff(x)
Upp


Out[8]:
$\displaystyle Uo \left(\frac{156 s^{12}}{x^{14}} - \frac{42 s^{6}}{x^{8}}\right)$

In [9]:
k=Upp.subs(x,x0)
print(k)
print(sp.latex(k))
k


9*2**(2/3)*Uo/s**2
\frac{9 \cdot 2^{\frac{2}{3}} Uo}{s^{2}}
Out[9]:
$\displaystyle \frac{9 \cdot 2^{\frac{2}{3}} Uo}{s^{2}}$

In [10]:
m=sp.symbols("m")

In [11]:
omega=sp.sqrt(k/m)
omega


Out[11]:
$\displaystyle \frac{3 \sqrt[3]{2} \sqrt{\frac{Uo}{m}}}{\left|{s}\right|}$

In [ ]: