In [1]:
%display latex

Ableitungen

In [2]:
x = var('x')
f = x^2 * exp(2*x+3)
f
Out[2]:
In [3]:
f.diff(x)
Out[3]:
In [4]:
f.diff(x).collect(exp(2*x+3))
Out[4]:
In [5]:
f.diff(x, x).collect(exp(2*x+3))
Out[5]:
In [6]:
f.diff(x).factor()
Out[6]:
In [7]:
df = f.diff(x)

Integration

In [8]:
ff = df.integral(x)
ff
Out[8]:
In [9]:
ff.factor()
Out[9]:

Matrizen

In [10]:
M = Matrix([[1,2,3], [4,5,6], [7,8,9]])
M
Out[10]:
In [11]:
M.kernel()
Out[11]:
In [12]:
M * vector([1,-2,1])
Out[12]:

Gewöhnliche Differentialgleichungen

In [13]:
phi = function('\phi')
y = phi(x)
y
Out[13]:
In [14]:
dgl = y.diff(x,x) + 4*y == 0
dgl
Out[14]:
In [15]:
lsg = desolve(dgl, y)
lsg
Out[15]:
In [16]:
lsg.variables()
Out[16]:
In [17]:
K1, K2, dummy = lsg.variables()
y1 = lsg.subs({K1: 1, K2: 0})
y2 = lsg.subs({K1: 0, K2: 1})
y1, y2
Out[17]:
In [18]:
pl1 = plot(y1, -5, 5)
pl2 = plot(y2, -5, 5, color='red')
pl1 + pl2
Out[18]:
In [19]:
dgl = y.diff(x) == sqrt(x*y)
dgl
Out[19]:
In [20]:
lsg = desolve(dgl, y)
lsg
Out[20]:
In [21]:
lsg2 = solve(lsg, y)[0]
lsg2
Out[21]:
In [22]:
glg2 = (lsg2^2).expand().canonicalize_radical()
glg2
Out[22]:
In [23]:
lsg3 = solve(glg2, y)
lsg3
Out[23]:
In [24]:
g = lsg3[0].rhs()
g.variables()
Out[24]:
In [25]:
C = g.variables()[0]
In [26]:
pl1 = plot(g.subs({C:0}), 0, 2, thickness=2)
pl2 = plot(g.subs({C:-1}), 0, 2, color='red', thickness=2)
In [27]:
pl1 + pl2
Out[27]:
In [28]:
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
Out[28]: