Grundlagen Funktionen

$f(x) = 1$

x -5 -4 -3 -2 -1 0 1 2 3 4 5
y 1 1 1 1 1 1 1 1 1 1 1
In [1]:
tabelle = []
for x in range(-5,6):
    tabelle.append((x,1))
print(tabelle)
[(-5, 1), (-4, 1), (-3, 1), (-2, 1), (-1, 1), (0, 1), (1, 1), (2, 1), (3, 1), (4, 1), (5, 1)]
In [2]:
print(tabelle)
[(-5, 1), (-4, 1), (-3, 1), (-2, 1), (-1, 1), (0, 1), (1, 1), (2, 1), (3, 1), (4, 1), (5, 1)]
In [3]:
print(tabelle)
[(-5, 1), (-4, 1), (-3, 1), (-2, 1), (-1, 1), (0, 1), (1, 1), (2, 1), (3, 1), (4, 1), (5, 1)]
In [4]:
from pygal import XY
from IPython.display import SVG
xy = XY()
xy.add("Funktion f(x)=1", tabelle)
SVG(xy.render())
Out[4]:
Pygal11-5-5-4-4-3-3-2-2-1-1001122334455-5: 111.384615384615394270.0-4: 168.30769230769232270.0-3: 1125.23076923076924270.0-2: 1182.15384615384616270.0-1: 1239.07692307692307270.00: 1296.0270.01: 1352.9230769230769270.02: 1409.84615384615387270.03: 1466.7692307692307270.04: 1523.6923076923076270.05: 1580.6153846153845270.0Funktion f(x)=1
In [5]:
def f(x):
    return 1
In [6]:
f(-5)
Out[6]:
1
In [7]:
f(-4)
Out[7]:
1
In [8]:
f(0)
Out[8]:
1
In [9]:
tabelle = []
for x in range(-5,6):
    tabelle.append((x,f(x)))
print(tabelle)
[(-5, 1), (-4, 1), (-3, 1), (-2, 1), (-1, 1), (0, 1), (1, 1), (2, 1), (3, 1), (4, 1), (5, 1)]
In [10]:
def f(x):
    return x
In [11]:
tabelle = []
for x in range(-5,6):
    tabelle.append((x,f(x)))
print(tabelle)
[(-5, -5), (-4, -4), (-3, -3), (-2, -2), (-1, -1), (0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5)]
In [12]:
from pygal import XY
from IPython.display import SVG
xy = XY()
xy.add("Funktion f(x)=x", tabelle)
SVG(xy.render())
Out[12]:
Pygal-5-5-4-4-3-3-2-2-1-1001122334455-5-5-4-4-3-3-2-2-1-1001122334455-5: -511.346153846153856529.6153846153846-4: -468.07692307692308477.6923076923077-3: -3124.8076923076923425.7692307692308-2: -2181.53846153846152373.8461538461538-1: -1238.26923076923077321.92307692307690: 0295.0270.01: 1351.7307692307692218.07692307692312: 2408.46153846153845166.15384615384623: 3465.1923076923077114.230769230769234: 4521.923076923076962.307692307692325: 5578.653846153846210.384615384615358Funktion f(x)=x

$f(x) = 2x²+4x-8$

In [13]:
def f(x):
    return 2*x**2 + 4*x - 8
In [14]:
tabelle = []
for x in range(-5,6):
    tabelle.append((x,f(x)))
print(tabelle)
[(-5, 22), (-4, 8), (-3, -2), (-2, -8), (-1, -10), (0, -8), (1, -2), (2, 8), (3, 22), (4, 40), (5, 62)]
In [15]:
from pygal import XY
from IPython.display import SVG
xy = XY()
xy.add("Funktion f(x)=2x²+4x-8", tabelle)
SVG(xy.render())
Out[15]:
Pygal-10-1000101020203030404050506060-5-5-4-4-3-3-2-2-1-1001122334455-5: 2211.230769230769239298.8461538461538-4: 867.38461538461539399.8076923076923-3: -2123.53846153846155471.9230769230769-2: -8179.6923076923077515.1923076923077-1: -10235.84615384615387529.61538461538460: -8292.0515.19230769230771: -2348.15384615384613471.92307692307692: 8404.3076923076923399.80769230769233: 22460.4615384615384298.84615384615384: 40516.6153846153845169.038461538461555: 62572.769230769230710.384615384615358Funktion f(x)=…Funktion f(x)=2x²+4x-8
In [16]:
def funktion(x):
    return 2*x+3
In [17]:
tabelle = []
for x in range(-5,6):
    tabelle.append((x,funktion(x)))
print(tabelle)
[(-5, -7), (-4, -5), (-3, -3), (-2, -1), (-1, 1), (0, 3), (1, 5), (2, 7), (3, 9), (4, 11), (5, 13)]
In [18]:
from pygal import XY
from IPython.display import SVG
xy = XY()
xy.add("Funktion funktion(x)=2x+3", tabelle)
SVG(xy.render())
Out[18]:
Pygal-6-6-4-4-2-2002244668810101212-5-5-4-4-3-3-2-2-1-1001122334455-5: -711.346153846153856529.6153846153846-4: -568.07692307692308477.6923076923077-3: -3124.8076923076923425.7692307692308-2: -1181.53846153846152373.8461538461538-1: 1238.26923076923077321.92307692307690: 3295.0270.01: 5351.7307692307692218.07692307692312: 7408.46153846153845166.15384615384623: 9465.1923076923077114.230769230769234: 11521.923076923076962.307692307692325: 13578.653846153846210.384615384615358Funktion funkt…Funktion funktion(x)=2x+3
In [19]:
funktion(-1.5)
Out[19]:
0.0
In [20]:
f(0)
Out[20]:
-8
In [21]:
a = 2
a
Out[21]:
2
In [22]:
a = 6
a
Out[22]:
6
In [23]:
f(0)
Out[23]:
-8
In [24]:
def f(x):
    return x
In [25]:
f(0)
Out[25]:
0
In [26]:
def g(x):
    return 2*x**2 + 4*x - 8
In [27]:
tabellef = []
for x in range(-5,6):
    tabellef.append((x,f(x)))
print(tabellef)
[(-5, -5), (-4, -4), (-3, -3), (-2, -2), (-1, -1), (0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5)]
In [28]:
tabelleg = []
for x in range(-5,6):
    tabelleg.append((x,g(x)))
print(tabelleg)
[(-5, 22), (-4, 8), (-3, -2), (-2, -8), (-1, -10), (0, -8), (1, -2), (2, 8), (3, 22), (4, 40), (5, 62)]
In [29]:
from pygal import XY
from IPython.display import SVG
xy = XY()
xy.add("Funktion f(x)=x", tabellef)
xy.add("Funktion f(x)=2x²+4x-8", tabelleg)
SVG(xy.render())
Out[29]:
Pygal-10-1000101020203030404050506060-5-5-4-4-3-3-2-2-1-1001122334455-5: -511.230769230769239493.5576923076923-4: -467.38461538461539486.34615384615387-3: -3123.53846153846155479.13461538461536-2: -2179.6923076923077471.9230769230769-1: -1235.84615384615387464.711538461538450: 0292.0457.51: 1348.15384615384613450.288461538461552: 2404.3076923076923443.07692307692313: 3460.4615384615384435.865384615384644: 4516.6153846153845428.653846153846135: 5572.7692307692307421.44230769230774-5: 2211.230769230769239298.8461538461538-4: 867.38461538461539399.8076923076923-3: -2123.53846153846155471.9230769230769-2: -8179.6923076923077515.1923076923077-1: -10235.84615384615387529.61538461538460: -8292.0515.19230769230771: -2348.15384615384613471.92307692307692: 8404.3076923076923399.80769230769233: 22460.4615384615384298.84615384615384: 40516.6153846153845169.038461538461555: 62572.769230769230710.384615384615358Funktion f(x)=xFunktion f(x)=…Funktion f(x)=2x²+4x-8