In [1]:
from sympy import *
init_printing()
In [2]:
2+2
Out[2]:
In [3]:
2*3
Out[3]:
In [4]:
2**3
Out[4]:
In [5]:
1/3
Out[5]:
In [6]:
1/0
In [7]:
3 * (1/3)
Out[7]:
In [8]:
3**100 * (1/3)**100
Out[8]:
In [9]:
drittel = Rational(1,3)
drittel
Out[9]:
In [10]:
3**100 * drittel**100
Out[10]:
In [11]:
drittel**100
Out[11]:
In [12]:
3**100
Out[12]:
In [13]:
(1/3)**1000
Out[13]:
In [14]:
3**1000 * (1/3)**1000
Beides ist nicht hilfreich
In [15]:
pi
Out[15]:
In [16]:
N(pi, 20)
Out[16]:
In [17]:
N(pi, 200)
Out[17]:
In [18]:
print(N(pi,200))
In [19]:
N(1/3, 200)
Out[19]:
Böse Falle!
In [20]:
N(Rational(1,3), 200)
Out[20]:
In [21]:
N(Rational(1,3), 200)**1000
Out[21]:
In [22]:
N(Rational(1,3), 200)**1000 * 3**1000
Out[22]:
In [23]:
3
Out[23]:
In [24]:
S(3)
Out[24]:
In [25]:
type(3)
Out[25]:
In [26]:
type(S(3))
Out[26]:
In [27]:
S(1)/3
Out[27]:
In [28]:
S(0.1)
Out[28]:
In [29]:
x = S('x')
x
Out[29]:
In [30]:
type(x)
Out[30]:
In [31]:
type(drittel)
Out[31]:
In [32]:
y = S('y')
y
Out[32]:
In [33]:
f = (x - y)**2
f
Out[33]:
In [34]:
x = 5
In [35]:
f
Out[35]:
In [36]:
x
Out[36]:
Das $x$ in $f$ ist ein unerreichbares Objekt geworden. (Na ja, nicht wirklich.)
In [37]:
f.atoms()
Out[37]:
In [38]:
sqrt(81)
Out[38]:
In [39]:
sqrt(-81)
Out[39]:
In [40]:
I**2
Out[40]:
In [41]:
sqrt(243)
Out[41]:
In [42]:
sqrt(243.)
Out[42]:
In [43]:
sqrt(9*y**2)
Out[43]:
Annahmen über Variablen sind möglich.
In [44]:
factorial(5)
Out[44]:
In [45]:
factorial(70)
Out[45]:
In [46]:
N(factorial(70))
Out[46]:
In [47]:
sin(pi)
Out[47]:
In [48]:
cos(pi)
Out[48]:
In [49]:
tan(pi/2)
Out[49]:
In [50]:
print(tan(pi/2))
In [51]:
?zoo
In [52]:
alpha = Symbol('alpha')
alpha
Out[52]:
In [53]:
exp(1)
Out[53]:
In [54]:
e
In [55]:
log(exp(1))
Out[55]:
In [56]:
abs(-1)
Out[56]:
In [57]:
x = Symbol('x')
y = Symbol('y')
In [58]:
f = (x-y)*(x+y)
f
Out[58]:
In [59]:
f.expand()
Out[59]:
In [60]:
expand(f)
Out[60]:
In [61]:
f.expand().factor()
Out[61]:
In [62]:
g = (x**2-y**2)/(x-y)
g
Out[62]:
In [63]:
g.ratsimp()
Out[63]:
In [64]:
g.simplify()
Out[64]:
In [65]:
h = x*x**y
h
Out[65]:
In [66]:
h.powsimp()
Out[66]:
In [67]:
h.powsimp().expand()
Out[67]:
In [68]:
f = (sin(2*x)+cos(x)) / ((sin(2*x)**2 - cos(x)**2) * (sin(2*x)-cos(x)))
f
Out[68]:
In [69]:
f.simplify()
Out[69]:
In [70]:
f.ratsimp()
Out[70]:
In [71]:
f.trigsimp()
Out[71]:
In [72]:
f.expand()
Out[72]:
In [73]:
f.expand(numer=True)
Out[73]:
In [74]:
f.expand(numer=True, trig=True)
Out[74]:
In [75]:
f.expand(numer=True, trig=True).factor()
Out[75]:
In [76]:
f.expand(gibtsnich=True)
Out[76]:
In [ ]: