Eulerove i trigonometrijske supstitucije


In [1]:
using SymPy

In [3]:
x=symbols("x",real=true)


Out[3]:
\begin{equation*}x\end{equation*}

In [4]:
integrate(1/(x+sqrt(x^2+6*x+10)),x)


Out[4]:
\begin{equation*}\int \frac{1}{x + \sqrt{x^{2} + 6 x + 10}}\, dx\end{equation*}

In [5]:
integrate(1/(x-3+sqrt(1+x^2)))


Out[5]:
\begin{equation*}\int \frac{1}{x + \sqrt{x^{2} + 1} - 3}\, dx\end{equation*}

In [6]:
I₁=1/(x-3+sqrt(1+x^2))


Out[6]:
\begin{equation*}\frac{1}{x + \sqrt{x^{2} + 1} - 3}\end{equation*}

In [7]:
z=symbols("z",real=true)


Out[7]:
\begin{equation*}z\end{equation*}

In [8]:
I₂=subs(I₁,x,(1-z^2)/(2*z))


Out[8]:
\begin{equation*}\frac{1}{\sqrt{1 + \frac{\left(1 - z^{2}\right)^{2}}{4 z^{2}}} - 3 + \frac{1 - z^{2}}{2 z}}\end{equation*}

In [9]:
simplify(I₂)


Out[9]:
\begin{equation*}- \frac{2 z \left|{z}\right|}{- z \sqrt{4 z^{2} + \left(z^{2} - 1\right)^{2}} + 6 z \left|{z}\right| + \left(z^{2} - 1\right) \left|{z}\right|}\end{equation*}

In [10]:
I₂=subs(I₁,sqrt(x^2+1),x+z)


Out[10]:
\begin{equation*}\frac{1}{2 x + z - 3}\end{equation*}

In [11]:
I₃=subs(I₂,x,(1-z^2)/(2*z))


Out[11]:
\begin{equation*}\frac{1}{z - 3 + \frac{1 - z^{2}}{z}}\end{equation*}

In [12]:
# Množi s dx
I₄=I₃*(-1)*(1+z^2)/(2*z^2)


Out[12]:
\begin{equation*}- \frac{z^{2} + 1}{2 z^{2} \left(z - 3 + \frac{1 - z^{2}}{z}\right)}\end{equation*}

In [13]:
I₄=simplify(I₄)


Out[13]:
\begin{equation*}\frac{z^{2} + 1}{2 z \left(3 z - 1\right)}\end{equation*}

In [14]:
I₅=integrate(I₄,z)


Out[14]:
\begin{equation*}\frac{z}{6} - \frac{\log{\left(z \right)}}{2} + \frac{5 \log{\left(z - \frac{1}{3} \right)}}{9}\end{equation*}

In [15]:
# Vratimo supstitucije
I₆=subs(I₅,(1-z^2)/(2*z),x)


Out[15]:
\begin{equation*}\frac{z}{6} - \frac{\log{\left(z \right)}}{2} + \frac{5 \log{\left(z - \frac{1}{3} \right)}}{9}\end{equation*}

In [16]:
I₆=subs(I₅,z,-x+sqrt(x^2+1))


Out[16]:
\begin{equation*}- \frac{x}{6} + \frac{\sqrt{x^{2} + 1}}{6} - \frac{\log{\left(- x + \sqrt{x^{2} + 1} \right)}}{2} + \frac{5 \log{\left(- x + \sqrt{x^{2} + 1} - \frac{1}{3} \right)}}{9}\end{equation*}

In [17]:
# Primjer 1.12
integrate(x^2*sqrt(4*x^2+9))


Out[17]:
\begin{equation*}\frac{x^{5}}{\sqrt{4 x^{2} + 9}} + \frac{27 x^{3}}{8 \sqrt{4 x^{2} + 9}} - \frac{81 x \operatorname{asinh}{\left(\frac{2 \left|{x}\right|}{3} \right)}}{64 \left|{x}\right|} + \frac{81 x}{32 \sqrt{4 x^{2} + 9}}\end{equation*}

Binomni integral


In [20]:
# Primjer 1.13
I₇=((3*x-x*x*x)^(1//3))


Out[20]:
\begin{equation*}\sqrt[3]{- x^{3} + 3 x}\end{equation*}

In [21]:
integrate(I₇,x)


Out[21]:
\begin{equation*}\int \sqrt[3]{- x^{3} + 3 x}\, dx\end{equation*}

Integriranje razvoja u red potencija


In [22]:
s₁=series(exp(x),x)


Out[22]:
\begin{equation*}1 + x + \frac{x^{2}}{2} + \frac{x^{3}}{6} + \frac{x^{4}}{24} + \frac{x^{5}}{120} + O\left(x^{6}\right)\end{equation*}

In [23]:
s₂=series(exp(x),x,0,10)


Out[23]:
\begin{equation*}1 + x + \frac{x^{2}}{2} + \frac{x^{3}}{6} + \frac{x^{4}}{24} + \frac{x^{5}}{120} + \frac{x^{6}}{720} + \frac{x^{7}}{5040} + \frac{x^{8}}{40320} + \frac{x^{9}}{362880} + O\left(x^{10}\right)\end{equation*}

Razvoj u red funkcije $f(x)=e^{-x^2}$


In [24]:
s₃=subs(s₂,x,(-x^2))


Out[24]:
\begin{equation*}1 - x^{2} + \frac{x^{4}}{2} - \frac{x^{6}}{6} + \frac{x^{8}}{24} - \frac{x^{10}}{120} + \frac{x^{12}}{720} - \frac{x^{14}}{5040} + \frac{x^{16}}{40320} - \frac{x^{18}}{362880} + O\left(x^{20}\right)\end{equation*}

In [25]:
s₄=integrate(s₃,x)


Out[25]:
\begin{equation*}x - \frac{x^{3}}{3} + \frac{x^{5}}{10} - \frac{x^{7}}{42} + \frac{x^{9}}{216} - \frac{x^{11}}{1320} + \frac{x^{13}}{9360} - \frac{x^{15}}{75600} + \frac{x^{17}}{685440} - \frac{x^{19}}{6894720} + O\left(x^{21}\right)\end{equation*}

In [28]:
# Uklonimo član O(x^21) 
s₆=s₄.removeO()


Out[28]:
\begin{equation*}- \frac{x^{19}}{6894720} + \frac{x^{17}}{685440} - \frac{x^{15}}{75600} + \frac{x^{13}}{9360} - \frac{x^{11}}{1320} + \frac{x^{9}}{216} - \frac{x^{7}}{42} + \frac{x^{5}}{10} - \frac{x^{3}}{3} + x\end{equation*}

In [30]:
# Izračunajmo vrijednost u točki x=0.1
subs(s₆,x,0.1)


Out[30]:
\begin{equation*}0.0996676642903364\end{equation*}

Primjer 1.14 b)


In [31]:
# Maclaurin-ov red za sin(x)
s₁=series(sin(x),x,0,10)


Out[31]:
\begin{equation*}x - \frac{x^{3}}{6} + \frac{x^{5}}{120} - \frac{x^{7}}{5040} + \frac{x^{9}}{362880} + O\left(x^{10}\right)\end{equation*}

In [33]:
# Razvoj u red za sin(x)/x
s₂=simplify(s₁/x)


Out[33]:
\begin{equation*}1 - \frac{x^{2}}{6} + \frac{x^{4}}{120} - \frac{x^{6}}{5040} + \frac{x^{8}}{362880} + O\left(x^{9}\right)\end{equation*}

In [34]:
# Ukonimo O() clan
s₃=s₂.removeO()


Out[34]:
\begin{equation*}\frac{x^{8}}{362880} - \frac{x^{6}}{5040} + \frac{x^{4}}{120} - \frac{x^{2}}{6} + 1\end{equation*}

In [35]:
# Integrirajmo
s₄=integrate(s₃,x)


Out[35]:
\begin{equation*}\frac{x^{9}}{3265920} - \frac{x^{7}}{35280} + \frac{x^{5}}{600} - \frac{x^{3}}{18} + x\end{equation*}

In [ ]: