CoCalc Public FilesAnalýza.sagews
Author: Roman Plch
Views : 314
Compute Environment: Ubuntu 20.04 (Default)
%typeset_mode True


diff(exp(-x^2),x)

$\displaystyle -2 \, x e^{\left(-x^{2}\right)}$
'diff(exp(-x^2),x)'

diff(exp(-x^2),x)
diff(exp(-x^2),x,2)

$\displaystyle 4 \, x^{2} e^{\left(-x^{2}\right)} - 2 \, e^{\left(-x^{2}\right)}$
diff(log(x/(x^2+1)),x)

$\displaystyle -\frac{{\left(x^{2} + 1\right)} {\left(\frac{2 \, x^{2}}{{\left(x^{2} + 1\right)}^{2}} - \frac{1}{x^{2} + 1}\right)}}{x}$
diff(log(x/(x^2+1)),x).simplify_full()

$\displaystyle -\frac{x^{2} - 1}{x^{3} + x}$


diff(x^(x^x),x)

$\displaystyle {\left(x^{x} {\left(\log\left(x\right) + 1\right)} \log\left(x\right) + \frac{x^{x}}{x}\right)} x^{\left(x^{x}\right)}$
diff(x^(x^x),x).collect(log(x))

$\displaystyle x^{x} x^{\left(x^{x}\right)} \log\left(x\right)^{2} + x^{x} x^{\left(x^{x}\right)} \log\left(x\right) + \frac{x^{x} x^{\left(x^{x}\right)}}{x}$
%html
Derivace funkce dané implicitně

Derivace funkce dané implicitně
reset()

var('x')

$\displaystyle x$
y = function('y')(x);y

$\displaystyle y\left(x\right)$
dy=y.diff(x);dy

$\displaystyle \frac{\partial}{\partial x}y\left(x\right)$
var('c')

$\displaystyle c$
eq=x^2+y^2==c;eq

$\displaystyle x^{2} + y\left(x\right)^{2} = c$
dc=diff(eq,x);dc

$\displaystyle 2 \, y\left(x\right) \frac{\partial}{\partial x}y\left(x\right) + 2 \, x = 0$
yx=solve(dc,dy);yx

[$\displaystyle \frac{\partial}{\partial x}y\left(x\right) = -\frac{x}{y\left(x\right)}$]
dcc=diff(eq,x,2);dcc

$\displaystyle 2 \, \frac{\partial}{\partial x}y\left(x\right)^{2} + 2 \, y\left(x\right) \frac{\partial^{2}}{(\partial x)^{2}}y\left(x\right) + 2 = 0$
dyy=y.diff(x,2);dyy

$\displaystyle \frac{\partial^{2}}{(\partial x)^{2}}y\left(x\right)$
yxx=solve(dcc,dyy);yxx

[$\displaystyle \frac{\partial^{2}}{(\partial x)^{2}}y\left(x\right) = -\frac{\frac{\partial}{\partial x}y\left(x\right)^{2} + 1}{y\left(x\right)}$]
yxx[0].rhs().subs(yx).simplify_full()

$\displaystyle -\frac{x^{2} + y\left(x\right)^{2}}{y\left(x\right)^{3}}$
%html
Parciální derivace

Parciální derivace
var('x,y,a')

($\displaystyle x$, $\displaystyle y$, $\displaystyle a$)
diff(exp(a*x*y^2),x).diff(y,2)

$\displaystyle 4 \, a^{3} x^{2} y^{4} e^{\left(a x y^{2}\right)} + 10 \, a^{2} x y^{2} e^{\left(a x y^{2}\right)} + 2 \, a e^{\left(a x y^{2}\right)}$
diff(exp(a*x*y^2),x,1,y,2)

$\displaystyle 4 \, a^{3} x^{2} y^{4} e^{\left(a x y^{2}\right)} + 10 \, a^{2} x y^{2} e^{\left(a x y^{2}\right)} + 2 \, a e^{\left(a x y^{2}\right)}$
diff(sin(x+y)/y^4, x,5,y,2)

$\displaystyle -\frac{\cos\left(x + y\right)}{y^{4}} + \frac{8 \, \sin\left(x + y\right)}{y^{5}} + \frac{20 \, \cos\left(x + y\right)}{y^{6}}$
var('n')

$\displaystyle n$


%html
Derivace funkce (ve smyslu datové struktury v Sage)

Derivace funkce (ve smyslu datové struktury v Sage)


g(x)=x^n*exp(sin(x));g

$\displaystyle x \ {\mapsto}\ x^{n} e^{\sin\left(x\right)}$
g.diff()

$\displaystyle x \ {\mapsto}\ \left(n x^{n - 1} e^{\sin\left(x\right)} + x^{n} \cos\left(x\right) e^{\sin\left(x\right)}\right)$
g.diff()(pi/6)

$\displaystyle \left(\left(\frac{1}{6} \, \pi\right)^{n - 1} n e^{\frac{1}{2}} + \frac{1}{2} \, \sqrt{3} \left(\frac{1}{6} \, \pi\right)^{n} e^{\frac{1}{2}}\right)$
g.diff().diff()

$\displaystyle \left(\begin{array}{r} x \ {\mapsto}\ {\left(n - 1\right)} n x^{n - 2} e^{\sin\left(x\right)} + 2 \, n x^{n - 1} \cos\left(x\right) e^{\sin\left(x\right)} + x^{n} \cos\left(x\right)^{2} e^{\sin\left(x\right)} - x^{n} e^{\sin\left(x\right)} \sin\left(x\right) \end{array}\right)$
f(x,y)=x^2*y+2*x*y+x

f.diff() #vypočte obě parciální derivace

$\displaystyle \left( x, y \right) \ {\mapsto} \ \left(2 \, x y + 2 \, y + 1,\,x^{2} + 2 \, x\right)$
f.diff(x); f.diff(y)

$\displaystyle \left( x, y \right) \ {\mapsto} \ 2 \, x y + 2 \, y + 1$
$\displaystyle \left( x, y \right) \ {\mapsto} \ x^{2} + 2 \, x$
f.diff(x).diff(y) #smíšená parciální derivace vzhledem k x a y.

$\displaystyle \left( x, y \right) \ {\mapsto} \ 2 \, x + 2$
F=piecewise([[(-infinity,0),sin(x)],[[0,0],arctan(x)],[(0,infinity),arctan(x)]], var=x)

plot(F(x), (x,-3*pi,3*pi))

F=piecewise([[(-infinity,0),sin(x)],[[0,0],arctan(x)],[(0,infinity),arctan(x)]], var=x)

F.derivative()

(0, 0, 0)*D[0]piecewise(x|-->sin(x) on (-oo, 0), x|-->arctan(x) on {0}, x|-->arctan(x) on (0, +oo); x) + D[1]piecewise(x|-->sin(x) on (-oo, 0), x|-->arctan(x) on {0}, x|-->arctan(x) on (0, +oo); x)




i=integral(x/(x^3+1), x);i

$\displaystyle \frac{1}{3} \, \sqrt{3} \arctan\left(\frac{1}{3} \, \sqrt{3} {\left(2 \, x - 1\right)}\right) + \frac{1}{6} \, \log\left(x^{2} - x + 1\right) - \frac{1}{3} \, \log\left(x + 1\right)$
diff(i,x).simplify_full()

$\displaystyle \frac{x}{x^{3} + 1}$
i=integral(x/(x^5+1),x);i

$\displaystyle -\frac{2 \, \sqrt{5} \arctan\left(\frac{4 \, x + \sqrt{5} - 1}{\sqrt{2 \, \sqrt{5} + 10}}\right)}{5 \, \sqrt{2 \, \sqrt{5} + 10}} + \frac{2 \, \sqrt{5} \arctan\left(\frac{4 \, x - \sqrt{5} - 1}{\sqrt{-2 \, \sqrt{5} + 10}}\right)}{5 \, \sqrt{-2 \, \sqrt{5} + 10}} - \frac{\log\left(2 \, x^{2} - x {\left(\sqrt{5} + 1\right)} + 2\right)}{5 \, {\left(\sqrt{5} + 1\right)}} + \frac{\log\left(2 \, x^{2} + x {\left(\sqrt{5} - 1\right)} + 2\right)}{5 \, {\left(\sqrt{5} - 1\right)}} - \frac{1}{5} \, \log\left(x + 1\right)$
diff(i,x).simplify_full()

$\displaystyle \frac{x}{x^{5} + 1}$
integral(2*x*(x^2+1)^24, x)

$\displaystyle \frac{1}{25} \, {\left(x^{2} + 1\right)}^{25}$
Určitý integrál
i=integral(x/(x^3+1), (x,1,2));i

$\displaystyle \frac{1}{18} \, \sqrt{3} \pi - \frac{1}{6} \, \log\left(3\right) + \frac{1}{3} \, \log\left(2\right)$
i.n()

$\displaystyle 0.350246906114333$
numerical_integral(x/(x^3+1), 1,2)

($\displaystyle 0.3502469061143331$, $\displaystyle 3.888521794718582 \times 10^{-15}$)
integral(1/x^2, (x,-1,1)

Error in lines 1-1 Traceback (most recent call last): File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1188, in execute flags=compile_flags) in namespace, locals File "<string>", line 1 integral(Integer(1)/x**Integer(2), (x,-Integer(1),Integer(1)) ^ SyntaxError: unexpected EOF while parsing
plot(1/x^2, (x,-1,1), ymin=0, ymax=10)

%html
Nevlastní integrál

Nevlastní integrál
var('t')

$\displaystyle t$
integral(t^4*log(t)^2/(1+3*t^2)^3, t,0,oo)

$\displaystyle \frac{1}{576} \, \sqrt{3} \pi^{3} + \frac{1}{576} \, \sqrt{3} \pi \log\left(3\right)^{2} - \frac{1}{108} \, \sqrt{3} \pi \log\left(3\right) + \frac{1}{216} \, \sqrt{3} \pi$
integral(exp(arcsin(x)), x,0,1)

$\displaystyle \frac{1}{2} \, e^{\left(\frac{1}{2} \, \pi\right)} - \frac{1}{2}$
integral(sqrt(9-x^2), x)

$\displaystyle \frac{1}{2} \, \sqrt{-x^{2} + 9} x + \frac{9}{2} \, \arcsin\left(\frac{1}{3} \, x\right)$
Sumace
var('k,n,a,y')

($\displaystyle k$, $\displaystyle n$, $\displaystyle a$, $\displaystyle y$)
sum(k^7, k,1,20)

$\displaystyle 3877286700$
sum(k^7, k,1,n)

$\displaystyle \frac{1}{8} \, n^{8} + \frac{1}{2} \, n^{7} + \frac{7}{12} \, n^{6} - \frac{7}{24} \, n^{4} + \frac{1}{12} \, n^{2}$
sum(1/(k^2-4), k,3,oo)

$\displaystyle \frac{25}{48}$


t=taylor(sin(tan(x))-tan(sin(x)), x,0,25);t

$\displaystyle \frac{48074332710505411}{4616431560515174400000} \, x^{25} - \frac{374694625074883}{6690480522485760000} \, x^{23} - \frac{2097555460001}{7602818775552000} \, x^{21} - \frac{1664108363}{1905468364800} \, x^{19} - \frac{10193207}{4358914560} \, x^{17} - \frac{311148869}{54486432000} \, x^{15} - \frac{95}{7392} \, x^{13} - \frac{1913}{75600} \, x^{11} - \frac{29}{756} \, x^{9} - \frac{1}{30} \, x^{7}$
type(t)

<type 'sage.symbolic.expression.Expression'>
f=sin(tan(x))-tan(sin(x))

t1=f.series(x,25);t1

$\displaystyle {(-\frac{1}{30})} x^{7} + {(-\frac{29}{756})} x^{9} + {(-\frac{1913}{75600})} x^{11} + {(-\frac{95}{7392})} x^{13} + {(-\frac{311148869}{54486432000})} x^{15} + {(-\frac{10193207}{4358914560})} x^{17} + {(-\frac{1664108363}{1905468364800})} x^{19} + {(-\frac{2097555460001}{7602818775552000})} x^{21} + {(-\frac{374694625074883}{6690480522485760000})} x^{23} + \mathcal{O}\left(x^{25}\right)$
type(t1)

<type 'sage.symbolic.series.SymbolicSeries'>


t1.coefficients()

[[$\displaystyle 0$, $\displaystyle 0$], [$\displaystyle 0$, $\displaystyle 1$], [$\displaystyle 0$, $\displaystyle 2$], [$\displaystyle 0$, $\displaystyle 3$], [$\displaystyle 0$, $\displaystyle 4$], [$\displaystyle 0$, $\displaystyle 5$], [$\displaystyle 0$, $\displaystyle 6$], [$\displaystyle -\frac{1}{30}$, $\displaystyle 7$], [$\displaystyle 0$, $\displaystyle 8$], [$\displaystyle -\frac{29}{756}$, $\displaystyle 9$], [$\displaystyle 0$, $\displaystyle 10$], [$\displaystyle -\frac{1913}{75600}$, $\displaystyle 11$], [$\displaystyle 0$, $\displaystyle 12$], [$\displaystyle -\frac{95}{7392}$, $\displaystyle 13$], [$\displaystyle 0$, $\displaystyle 14$], [$\displaystyle -\frac{311148869}{54486432000}$, $\displaystyle 15$], [$\displaystyle 0$, $\displaystyle 16$], [$\displaystyle -\frac{10193207}{4358914560}$, $\displaystyle 17$], [$\displaystyle 0$, $\displaystyle 18$], [$\displaystyle -\frac{1664108363}{1905468364800}$, $\displaystyle 19$], [$\displaystyle 0$, $\displaystyle 20$], [$\displaystyle -\frac{2097555460001}{7602818775552000}$, $\displaystyle 21$], [$\displaystyle 0$, $\displaystyle 22$], [$\displaystyle -\frac{374694625074883}{6690480522485760000}$, $\displaystyle 23$], [$\displaystyle 0$, $\displaystyle 24$]]
t2=t1.truncate();t2

$\displaystyle -\frac{374694625074883}{6690480522485760000} \, x^{23} - \frac{2097555460001}{7602818775552000} \, x^{21} - \frac{1664108363}{1905468364800} \, x^{19} - \frac{10193207}{4358914560} \, x^{17} - \frac{311148869}{54486432000} \, x^{15} - \frac{95}{7392} \, x^{13} - \frac{1913}{75600} \, x^{11} - \frac{29}{756} \, x^{9} - \frac{1}{30} \, x^{7}$
type(t2)

<type 'sage.symbolic.expression.Expression'>
taylor(x*y^3,(x,1),(y,-1),4)

$\displaystyle {\left(x - 1\right)} {\left(y + 1\right)}^{3} - 3 \, {\left(x - 1\right)} {\left(y + 1\right)}^{2} + {\left(y + 1\right)}^{3} + 3 \, {\left(x - 1\right)} {\left(y + 1\right)} - 3 \, {\left(y + 1\right)}^{2} - x + 3 \, y + 3$
%html
Výpočty limit


Výpočty limit
limit( cos(x)^(1/x^3), x=0)

$\displaystyle \mathit{und}$
limit( cos(x)^(1/x^3), x=0, dir='plus')

$\displaystyle 0$
limit( cos(x)^(1/x^3), x=0, dir='minus')

$\displaystyle +\infty$
var('a,b')

($\displaystyle a$, $\displaystyle b$)
y=exp(a*x)*cos(b*x);y

$\displaystyle \cos\left(b x\right) e^{\left(a x\right)}$
assume(a>0, b>0)

limit(y, x=-oo)

$\displaystyle 0$
%html
Diferenciální rovnice

Diferenciální rovnice
y = function('y')(x)

ode=x*diff(y,x)==y;ode

$\displaystyle x \frac{\partial}{\partial x}y\left(x\right) = y\left(x\right)$
sol=desolve(ode,y);expand(sol)

$\displaystyle C x$
desolve(ode, y, ics=[1,1])

$\displaystyle x$