In [1]:
versioninfo()


Julia Version 1.4.1
Commit 381693d3df* (2020-04-14 17:20 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-8.0.1 (ORCJIT, skylake)
Environment:
  JULIA_NUM_THREADS = 4

In [2]:
# Ovu naredbu je potrebno izvršiti sam jednom, učita se paket SymPy
using SymPy

In [3]:
# Ova naredba daje popis svih djelova paketa, uglavnom su to funkcije. Klik na lijevoj strani otvara scroll prozor, 
# drugi klik ponovo pokazuje sve. Dvostruki klik kolabira izalaz.
varinfo(SymPy)


Out[3]:
name size summary
@symfuns 0 bytes SymPy.var"#@symfuns"
@syms 0 bytes SymPy.var"#@syms"
@vars 0 bytes SymPy.var"#@vars"
Abs 0 bytes typeof(Abs)
And 0 bytes typeof(And)
DiracDelta 0 bytes typeof(DiracDelta)
Eq 0 bytes typeof(Eq)
Equality 0 bytes typeof(Equality)
False 16 bytes Sym
Ge 0 bytes typeof(Ge)
GreaterThan 0 bytes typeof(GreaterThan)
Gt 0 bytes typeof(Gt)
Heaviside 0 bytes typeof(Heaviside)
IM 16 bytes Sym
Le 0 bytes typeof(Le)
LessThan 0 bytes typeof(LessThan)
Lt 40 bytes UnionAll
Max 0 bytes typeof(Max)
Min 0 bytes typeof(Min)
N 0 bytes typeof(N)
Ne 0 bytes typeof(Ne)
Not 0 bytes typeof(Not)
Or 0 bytes typeof(Or)
PI 16 bytes Sym
Permutation 0 bytes typeof(Permutation)
PermutationGroup 0 bytes typeof(PermutationGroup)
Q 47.499 KiB Module
StrictGreaterThan 0 bytes typeof(StrictGreaterThan)
StrictLessThan 0 bytes typeof(StrictLessThan)
Sym 192 bytes DataType
SymFunction 200 bytes DataType
SymMatrix 192 bytes DataType
SymPermutation 192 bytes DataType
SymPermutationGroup 192 bytes DataType
SymPy 840.453 KiB Module
True 16 bytes Sym
Unequality 0 bytes typeof(Unequality)
VectorField 200 bytes DataType
Wild 0 bytes typeof(Wild)
Xor 0 bytes typeof(Xor)
prod 0 bytes typeof(prod)
apart 0 bytes typeof(apart)
ask 0 bytes typeof(ask)
bernfrac 0 bytes typeof(bernfrac)
cancel 0 bytes typeof(cancel)
conjugate 0 bytes typeof(conjugate)
cse 0 bytes typeof(cse)
degree 0 bytes typeof(degree)
denom 0 bytes typeof(denom)
doctests 0 bytes typeof(doctests)
dsolve 0 bytes typeof(dsolve)
e1 0 bytes typeof(e1)
ei 0 bytes typeof(ei)
elements 0 bytes typeof(elements)
ellipk 0 bytes typeof(ellipk)
expand 0 bytes typeof(expand)
expj 0 bytes typeof(expj)
expjpi 0 bytes typeof(expjpi)
fac 0 bytes typeof(fac)
factor 0 bytes typeof(factor)
fib 0 bytes typeof(fib)
flatten 0 bytes typeof(flatten)
free_symbols 0 bytes typeof(free_symbols)
hessian 0 bytes typeof(hessian)
import_from 0 bytes typeof(import_from)
integrate 0 bytes typeof(integrate)
interpolate 0 bytes typeof(interpolate)
intersection 0 bytes typeof(intersection)
intervals 0 bytes typeof(intervals)
isolate 0 bytes typeof(isolate)
isprime 0 bytes typeof(isprime)
lambdify 0 bytes typeof(lambdify)
lhs 0 bytes typeof(lhs)
limit 0 bytes typeof(limit)
line_integrate 0 bytes typeof(line_integrate)
linsolve 0 bytes typeof(linsolve)
ln 0 bytes typeof(ln)
monitor 0 bytes typeof(monitor)
multiplicity 0 bytes typeof(multiplicity)
nint 0 bytes typeof(nint)
nonlinsolve 0 bytes typeof(nonlinsolve)
nroots 0 bytes typeof(nroots)
nsimplify 0 bytes typeof(nsimplify)
nsolve 0 bytes typeof(nsolve)
numer 0 bytes typeof(numer)
ode_order 0 bytes typeof(ode_order)
oo 16 bytes Sym
pdsolve 0 bytes typeof(pdsolve)
plot_implicit 0 bytes typeof(plot_implicit)
plot_parametric_surface 0 bytes typeof(plot_parametric_surface)
prime 0 bytes typeof(prime)
real_root 0 bytes typeof(real_root)
real_roots 0 bytes typeof(real_roots)
refine 0 bytes typeof(refine)
rgamma 0 bytes typeof(rgamma)
rhs 0 bytes typeof(rhs)
root 0 bytes typeof(root)
rootof 0 bytes typeof(rootof)
roots 0 bytes typeof(roots)
rsolve 0 bytes typeof(rsolve)
series 0 bytes typeof(series)
simplify 0 bytes typeof(simplify)
solve 0 bytes typeof(solve)
solveset 0 bytes typeof(solveset)
srepr 0 bytes typeof(srepr)
subs 0 bytes typeof(subs)
summation 0 bytes typeof(summation)
symbols 0 bytes typeof(symbols)
sympify 0 bytes typeof(sympify)
sympy 8 bytes PyCall.PyObject
sympy_plotting 0 bytes Nothing
timing 0 bytes typeof(timing)
together 0 bytes typeof(together)
transpositions 0 bytes typeof(transpositions)
unflatten 0 bytes typeof(unflatten)
zoo 16 bytes Sym
¬ 0 bytes typeof(¬)
0 bytes typeof(∧)
0 bytes typeof(∨)
0 bytes typeof(≦)
0 bytes typeof(≧)
0 bytes typeof(≪)
0 bytes typeof(≫)
0 bytes typeof(⩵)

In [4]:
# Izracunajmo nekoliko integrala. Prikazuje se samo zadnji rezultat prozora
x=Sym("x")
integrate(x^2*sin(x))


Out[4]:
\begin{equation*}- x^{2} \cos{\left(x \right)} + 2 x \sin{\left(x \right)} + 2 \cos{\left(x \right)}\end{equation*}

In [5]:
integrate(exp(-x^2))


Out[5]:
\begin{equation*}\frac{\sqrt{\pi} \operatorname{erf}{\left(x \right)}}{2}\end{equation*}

In [6]:
# Primjer rekurzivne formule. Ovo traje malo duže
integrate(1/(1+x^2)^13)


Out[6]:
\begin{equation*}\frac{334639305 x^{23} + 3904125225 x^{21} + 20814564771 x^{19} + 67013911107 x^{17} + 144986993866 x^{15} + 221803567050 x^{13} + 245588699190 x^{11} + 197767334710 x^{9} + 114444262845 x^{7} + 46038446685 x^{5} + 12013258455 x^{3} + 1741541175 x}{2076180480 x^{24} + 24914165760 x^{22} + 137027911680 x^{20} + 456759705600 x^{18} + 1027709337600 x^{16} + 1644334940160 x^{14} + 1918390763520 x^{12} + 1644334940160 x^{10} + 1027709337600 x^{8} + 456759705600 x^{6} + 137027911680 x^{4} + 24914165760 x^{2} + 2076180480} + \frac{676039 \operatorname{atan}{\left(x \right)}}{4194304}\end{equation*}

In [7]:
# Kraća rekurzivna formula
integrate(1/(1+x^2)^3)


Out[7]:
\begin{equation*}\frac{3 x^{3} + 5 x}{8 x^{4} + 16 x^{2} + 8} + \frac{3 \operatorname{atan}{\left(x \right)}}{8}\end{equation*}

In [8]:
methods(diff)


Out[8]:
# 6 methods for generic function diff:

In [9]:
# Derivacija
diff(x^2*exp(sin(1/x)))


Out[9]:
\begin{equation*}2 x e^{\sin{\left(\frac{1}{x} \right)}} - e^{\sin{\left(\frac{1}{x} \right)}} \cos{\left(\frac{1}{x} \right)}\end{equation*}

In [10]:
# Racionanla funkcija trigonometrijskih funkcija (univerzalna trigonometrijska supstitucija)
integrate(1/((2+cos(x))*sin(x)))


Out[10]:
\begin{equation*}\frac{\log{\left(\tan^{2}{\left(\frac{x}{2} \right)} + 3 \right)}}{3} + \frac{\log{\left(\tan{\left(\frac{x}{2} \right)} \right)}}{3}\end{equation*}

Zadatak 1.5.e)


In [12]:
integrate(1/(4*sin(x)+3*cos(x)+5))


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

In [13]:
integrate(1/(sin(x)*(2+cos(x)-2*sin(x))))


Out[13]:
\begin{equation*}\frac{5 \log{\left(\tan{\left(\frac{x}{2} \right)} - 3 \right)}}{3} - \log{\left(\tan{\left(\frac{x}{2} \right)} - 1 \right)} + \frac{\log{\left(\tan{\left(\frac{x}{2} \right)} \right)}}{3}\end{equation*}

In [ ]:
# Ovo traje beskonačno?
# integrate(cos(x)^3/(sin(x)^2+sin(x)))

In [14]:
# Ovo je isti zadatak kao gore, ali traje kratko. Koristi se jednostavnija supstitucija. 
integrate((1-sin(x)^2)*cos(x)/(sin(x)^2+sin(x)))


Out[14]:
\begin{equation*}\log{\left(\sin{\left(x \right)} \right)} - \sin{\left(x \right)}\end{equation*}

In [15]:
# Ovo traje jako dugo i ne uspije izračunati nego vrati polazni integral
# integrate( (2*tan(x)+3)/(sin(x)^2+2*cos(x)^2))

Uz supstituciju $t=\tan(x)$ integral postaje jednostavan:


In [16]:
t=Sym("t")
I₁=integrate( (2*t+3)/(t^2+2))


Out[16]:
\begin{equation*}\log{\left(t^{2} + 2 \right)} + \frac{3 \sqrt{2} \operatorname{atan}{\left(\frac{\sqrt{2} t}{2} \right)}}{2}\end{equation*}

In [18]:
# Vratimo supstituciju natrag
I₂=convert(Function,I₁)
I₂(tan(x))


Out[18]:
\begin{equation*}\log{\left(\tan^{2}{\left(x \right)} + 2 \right)} + 2.12132034355964 \operatorname{atan}{\left(0.707106781186548 \tan{\left(x \right)} \right)}\end{equation*}

Zadatak 1.6


In [19]:
# Ovo traje beskonačno!
# I₄=integrate((1+sinh(x))/((2+cosh(x))*(3+sinh(x))),x)
# Program treba našu pomoć!!!

Univerzalna hiperbolna supstitucija

$t=\tanh(\frac{x}{2})$, $x=2\mathop{\mathrm{atanh}}(t)$, $dx=\displaystyle\frac{2}{1-t^2}dt$, $\sinh(x)=\displaystyle\frac{2t}{1-t^2}$, $\cosh(x)=\displaystyle\frac{1+t^2}{1-t^2}$


In [20]:
I₄=(1+sinh(x))/((2+cosh(x))*(3+sinh(x)))


Out[20]:
\begin{equation*}\frac{\sinh{\left(x \right)} + 1}{\left(\sinh{\left(x \right)} + 3\right) \left(\cosh{\left(x \right)} + 2\right)}\end{equation*}

In [22]:
# supstitucija za sinh(x)
I₅=subs(I₄,sinh(x),(2*t)/(1-t^2))


Out[22]:
\begin{equation*}\frac{\frac{2 t}{1 - t^{2}} + 1}{\left(\frac{2 t}{1 - t^{2}} + 3\right) \left(\cosh{\left(x \right)} + 2\right)}\end{equation*}

In [23]:
# Supstitucija za cosh(x)
I₆=subs(I₅,cosh(x),(1+t^2)/(1-t^2))


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

In [24]:
# Pomnožimo s dx
I₇=I₆*2/(1-t^2)


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

In [25]:
# Integriramo racionalnu funkciju 
I₈=integrate(I₇,t)


Out[25]:
\begin{equation*}\frac{\log{\left(t^{2} - 3 \right)}}{3} - \left(\frac{1}{3} - \frac{\sqrt{10}}{15}\right) \log{\left(t - \frac{1}{3} + \frac{\sqrt{10}}{3} \right)} - \left(\frac{\sqrt{10}}{15} + \frac{1}{3}\right) \log{\left(t - \frac{\sqrt{10}}{3} - \frac{1}{3} \right)}\end{equation*}

In [26]:
# Vratimo supstituciju natrag
I₉=subs(I₈,t,tanh(x/2))


Out[26]:
\begin{equation*}\frac{\log{\left(\tanh^{2}{\left(\frac{x}{2} \right)} - 3 \right)}}{3} - \left(\frac{1}{3} - \frac{\sqrt{10}}{15}\right) \log{\left(\tanh{\left(\frac{x}{2} \right)} - \frac{1}{3} + \frac{\sqrt{10}}{3} \right)} - \left(\frac{\sqrt{10}}{15} + \frac{1}{3}\right) \log{\left(\tanh{\left(\frac{x}{2} \right)} - \frac{\sqrt{10}}{3} - \frac{1}{3} \right)}\end{equation*}

In [ ]: