%display latex
x = var('x')
f = x^2 * exp(2*x+3)
f
f.diff(x)
f.diff(x).collect(exp(2*x+3))
f.diff(x, x).collect(exp(2*x+3))
f.diff(x).factor()
df = f.diff(x)
ff = df.integral(x)
ff
ff.factor()
M = Matrix([[1,2,3], [4,5,6], [7,8,9]])
M
M.kernel()
M * vector([1,-2,1])
phi = function('\phi')
y = phi(x)
y
dgl = y.diff(x,x) + 4*y == 0
dgl
lsg = desolve(dgl, y)
lsg
lsg.variables()
K1, K2, dummy = lsg.variables()
y1 = lsg.subs({K1: 1, K2: 0})
y2 = lsg.subs({K1: 0, K2: 1})
y1, y2
pl1 = plot(y1, -5, 5)
pl2 = plot(y2, -5, 5, color='red')
pl1 + pl2
dgl = y.diff(x) == sqrt(x*y)
dgl
lsg = desolve(dgl, y)
lsg
lsg2 = solve(lsg, y)[0]
lsg2
glg2 = (lsg2^2).expand().canonicalize_radical()
glg2
lsg3 = solve(glg2, y)
lsg3
g = lsg3[0].rhs()
g.variables()
C = g.variables()[0]
pl1 = plot(g.subs({C:0}), 0, 2, thickness=2)
pl2 = plot(g.subs({C:-1}), 0, 2, color='red', thickness=2)
pl1 + pl2
pl2a = plot(g.subs({C:-1}), 0, (3/2)^(2/3), color='red', thickness=2, linestyle="--")
pl2b = plot(g.subs({C:-1}), (3/2)^(2/3), 2, color='red', thickness=2)
pl3 = plot(g.subs({C:1}), 0, 1.4, color='green', thickness=2)
pl1 + pl2a + pl2b + pl3