SharedUkol5.sagewsOpen in CoCalc
%typeset_mode True


var('y,z')

($\displaystyle y$, $\displaystyle z$)
v=(x+y)^2+1/(x+y);show(v)

$\displaystyle {\left(x + y\right)}^{2} + \frac{1}{x + y}$
v.operands()

[$\displaystyle {\left(x + y\right)}^{2}$, $\displaystyle \frac{1}{x + y}$]
v1=v.subs({x+y:z});v1

$\displaystyle z^{2} + \frac{1}{z}$
v2=v1.simplify_full();v2

$\displaystyle \frac{z^{3} + 1}{z}$
v3=v2.subs(z=x+y);v3

$\displaystyle \frac{{\left(x + y\right)}^{3} + 1}{x + y}$
v4=v3.subs({x+y:z});v4

$\displaystyle \frac{z^{3} + 1}{z}$
v5=v4.partial_fraction(z);v5

$\displaystyle z^{2} + \frac{1}{z}$
v6=v5.subs(z=x+y);v6

$\displaystyle {\left(x + y\right)}^{2} + \frac{1}{x + y}$
reset()

var('z,u')

($\displaystyle z$, $\displaystyle u$)
v=x^2+2*x+1+1/(x^2+2*x+1);v

$\displaystyle x^{2} + 2 \, x + \frac{1}{x^{2} + 2 \, x + 1} + 1$
v.operands()

[$\displaystyle x^{2}$, $\displaystyle 2 \, x$, $\displaystyle \frac{1}{x^{2} + 2 \, x + 1}$, $\displaystyle 1$]
v3=((x+1)^4+1)/(x+1)^2;v3

$\displaystyle \frac{{\left(x + 1\right)}^{4} + 1}{{\left(x + 1\right)}^{2}}$
v3.partial_fraction().expand()

$\displaystyle x^{2} + 2 \, x + \frac{1}{x^{2} + 2 \, x + 1} + 1$
var('y')

$\displaystyle y$
p = ((x+1)^10-2*y)/(x+y)^10+1/(x+y)^9-x/(x+y)^10;p

$\displaystyle \frac{{\left(x + 1\right)}^{10} - 2 \, y}{{\left(x + y\right)}^{10}} + \frac{1}{{\left(x + y\right)}^{9}} - \frac{x}{{\left(x + y\right)}^{10}}$
p.operands()

[$\displaystyle \frac{{\left(x + 1\right)}^{10} - 2 \, y}{{\left(x + y\right)}^{10}}$, $\displaystyle \frac{1}{{\left(x + y\right)}^{9}}$, $\displaystyle -\frac{x}{{\left(x + y\right)}^{10}}$]
p1=p.subs({(x+1):u, x+y:z}).simplify_full();p1

$\displaystyle \frac{u^{10} - x - 2 \, y + z}{z^{10}}$
p1.subs(u=x+1).subs(z=x+y).show()

$\displaystyle \frac{{\left(x + 1\right)}^{10} - y}{{\left(x + y\right)}^{10}}$
pol=(2*x^2-x)*(2*x^2+x);pol

$\displaystyle {\left(2 \, x^{2} + x\right)} {\left(2 \, x^{2} - x\right)}$
p2=factor(pol);p2

$\displaystyle {\left(2 \, x + 1\right)} {\left(2 \, x - 1\right)} x^{2}$
p1=expand(pol);p1;p1.operands()

$\displaystyle 4 \, x^{4} - x^{2}$
[$\displaystyle 4 \, x^{4}$, $\displaystyle -x^{2}$]
var('t')

$\displaystyle t$
p1.subs({x^2:t, x^4:t^2}).factor().subs(t=x^2)

$\displaystyle {\left(4 \, x^{2} - 1\right)} x^{2}$
p2.operands()

[$\displaystyle 2 \, x + 1$, $\displaystyle 2 \, x - 1$, $\displaystyle x^{2}$]
p2.subs({2*x-1:t}).expand().collect(t).subs(t=2*x-1)

$\displaystyle {\left(2 \, x^{3} + x^{2}\right)} {\left(2 \, x - 1\right)}$
var('a')

$\displaystyle a$
r = (x^2 -a)/(x-sqrt(a));r.canonicalize_radical()

$\displaystyle x + \sqrt{a}$