Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lernen Implementierung von Identitäts-Quadratfunktionen in Python | Funktionen und Ihre Eigenschaften
Mathematik für Data Science

bookImplementierung von Identitäts-Quadratfunktionen in Python

Identitätsfunktion

Die Identitätsfunktion gibt den Eingabewert unverändert zurück und folgt der Form f(x)=xf(x) = x. In Python wird sie wie folgt implementiert:

# Identity Function
def identity_function(x):
    return x

Die Identitätsfunktion gibt den Eingabewert unverändert zurück und folgt der Form f(x)=xf(x)=x. Zur Visualisierung werden x-Werte von -10 bis 10 erzeugt, die Gerade geplottet, der Ursprung (0,0)(0,0) markiert sowie Achsenbeschriftungen und Gitterlinien zur besseren Übersicht hinzugefügt.

12345678910111213141516171819202122232425
import numpy as np import matplotlib.pyplot as plt # Identity Function def identity_function(x): return x x = np.linspace(-10, 10, 100) y = identity_function(x) plt.plot(x, y, label="f(x) = x", color='blue', linewidth=2) plt.scatter(0, 0, color='red', zorder=5) # Mark the origin # Add axes plt.axhline(0, color='black', linewidth=1) plt.axvline(0, color='black', linewidth=1) # Add labels plt.xlabel("x") plt.ylabel("f(x)") # Add grid plt.grid(True, linestyle='--', alpha=0.6) plt.legend() plt.title("Identity Function: f(x) = x") plt.show()
copy

Konstante Funktion

Eine konstante Funktion liefert immer denselben Ausgabewert, unabhängig vom Eingabewert. Sie folgt der Gleichung f(x)=cf(x) = c.

# Constant Function
def constant_function(x, c):
    return np.full_like(x, c)

Eine konstante Funktion liefert immer denselben Ausgabewert, unabhängig vom Eingabewert, und folgt der Form f(x)=cf(x) = c. Zur Visualisierung werden x-Werte von -10 bis 10 erzeugt und eine horizontale Linie bei y=5y = 5 gezeichnet. Das Diagramm enthält Achsen, Beschriftungen und ein Raster zur besseren Übersicht.

123456789101112131415161718
import numpy as np import matplotlib.pyplot as plt def constant_function(x, c): return np.full_like(x, c) x = np.linspace(-10, 10, 100) y = constant_function(x, c=5) plt.plot(x, y, label="f(x) = 5", color='blue', linewidth=2) plt.axhline(0, color='black', linewidth=1) plt.axvline(0, color='black', linewidth=1) plt.xlabel("x") plt.ylabel("f(x)") plt.grid(True, linestyle='--', alpha=0.6) plt.legend() plt.title("Constant Function: f(x) = 5") plt.show()
copy

Lineare Funktion

Eine lineare Funktion hat die Form f(x)=mx+bf(x) = mx + b, wobei mm die Steigung und bb den y-Achsenabschnitt darstellt.

# Linear Function
def linear_function(x, m, b):
    return m * x + b

Eine lineare Funktion hat die Form f(x)=mx+bf(x) = mx + b, wobei mm die Steigung und bb den y-Achsenabschnitt bezeichnet. Es werden x-Werte von -20 bis 20 erzeugt und die Funktion mit beiden Achsen, einem Raster und markierten Schnittpunkten dargestellt.

1234567891011121314151617181920
import numpy as np import matplotlib.pyplot as plt def linear_function(x, m, b): return m * x + b x = np.linspace(-20, 20, 400) y = linear_function(x, m=2, b=-5) plt.plot(x, y, color='blue', linewidth=2, label="f(x) = 2x - 5") plt.scatter(0, -5, color='red', label="Y-Intercept") plt.scatter(2.5, 0, color='green', label="X-Intercept") plt.axhline(0, color='black', linewidth=1) plt.axvline(0, color='black', linewidth=1) plt.xlabel("x") plt.ylabel("f(x)") plt.grid(True, linestyle='--', alpha=0.6) plt.legend() plt.title("Linear Function: f(x) = 2x - 5") plt.show()
copy

Quadratische Funktion

Eine quadratische Funktion folgt f(x)=ax2+bx+cf(x) = ax^2 + bx + c und erzeugt eine parabolische Kurve. Wichtige Merkmale sind der Scheitelpunkt und die Nullstellen.

# Quadratic Function
def quadratic_function(x):
    return x**2 - 4*x - 2

Eine quadratische Funktion folgt f(x)=ax2+bx+cf(x) = ax^2 + bx + c und bildet eine Parabel. Wir erzeugen x-Werte von -2 bis 6, stellen die Funktion grafisch dar und markieren den Scheitelpunkt sowie die Schnittpunkte mit den Achsen. Die Darstellung enthält beide Achsen, ein Raster und Beschriftungen.

12345678910111213141516171819202122232425
import numpy as np import matplotlib.pyplot as plt def quadratic_function(x): return x**2 - 4*x - 2 x = np.linspace(-2, 6, 200) y = quadratic_function(x) plt.plot(x, y, color='blue', linewidth=2, label="f(x) = x² - 4x - 2") plt.scatter(2, quadratic_function(2), color='red', label="Vertex (2, -6)") plt.scatter(0, quadratic_function(0), color='green', label="Y-Intercept (0, -2)") # X-intercepts from quadratic formula x1, x2 = (4 + np.sqrt(24)) / 2, (4 - np.sqrt(24)) / 2 plt.scatter([x1, x2], [0, 0], color='orange', label="X-Intercepts") plt.axhline(0, color='black', linewidth=1) plt.axvline(0, color='black', linewidth=1) plt.xlabel("x") plt.ylabel("f(x)") plt.grid(True, linestyle='--', alpha=0.6) plt.legend() plt.title("Quadratic Function: f(x) = x² - 4x - 2") plt.show()
copy
question mark

Welcher Code definiert korrekt eine quadratische Funktion in Python, die (f(x) = x^2 - 4x - 2) berechnet?

Select the correct answer

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 1. Kapitel 5

Fragen Sie AI

expand

Fragen Sie AI

ChatGPT

Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen

Awesome!

Completion rate improved to 1.96

bookImplementierung von Identitäts-Quadratfunktionen in Python

Swipe um das Menü anzuzeigen

Identitätsfunktion

Die Identitätsfunktion gibt den Eingabewert unverändert zurück und folgt der Form f(x)=xf(x) = x. In Python wird sie wie folgt implementiert:

# Identity Function
def identity_function(x):
    return x

Die Identitätsfunktion gibt den Eingabewert unverändert zurück und folgt der Form f(x)=xf(x)=x. Zur Visualisierung werden x-Werte von -10 bis 10 erzeugt, die Gerade geplottet, der Ursprung (0,0)(0,0) markiert sowie Achsenbeschriftungen und Gitterlinien zur besseren Übersicht hinzugefügt.

12345678910111213141516171819202122232425
import numpy as np import matplotlib.pyplot as plt # Identity Function def identity_function(x): return x x = np.linspace(-10, 10, 100) y = identity_function(x) plt.plot(x, y, label="f(x) = x", color='blue', linewidth=2) plt.scatter(0, 0, color='red', zorder=5) # Mark the origin # Add axes plt.axhline(0, color='black', linewidth=1) plt.axvline(0, color='black', linewidth=1) # Add labels plt.xlabel("x") plt.ylabel("f(x)") # Add grid plt.grid(True, linestyle='--', alpha=0.6) plt.legend() plt.title("Identity Function: f(x) = x") plt.show()
copy

Konstante Funktion

Eine konstante Funktion liefert immer denselben Ausgabewert, unabhängig vom Eingabewert. Sie folgt der Gleichung f(x)=cf(x) = c.

# Constant Function
def constant_function(x, c):
    return np.full_like(x, c)

Eine konstante Funktion liefert immer denselben Ausgabewert, unabhängig vom Eingabewert, und folgt der Form f(x)=cf(x) = c. Zur Visualisierung werden x-Werte von -10 bis 10 erzeugt und eine horizontale Linie bei y=5y = 5 gezeichnet. Das Diagramm enthält Achsen, Beschriftungen und ein Raster zur besseren Übersicht.

123456789101112131415161718
import numpy as np import matplotlib.pyplot as plt def constant_function(x, c): return np.full_like(x, c) x = np.linspace(-10, 10, 100) y = constant_function(x, c=5) plt.plot(x, y, label="f(x) = 5", color='blue', linewidth=2) plt.axhline(0, color='black', linewidth=1) plt.axvline(0, color='black', linewidth=1) plt.xlabel("x") plt.ylabel("f(x)") plt.grid(True, linestyle='--', alpha=0.6) plt.legend() plt.title("Constant Function: f(x) = 5") plt.show()
copy

Lineare Funktion

Eine lineare Funktion hat die Form f(x)=mx+bf(x) = mx + b, wobei mm die Steigung und bb den y-Achsenabschnitt darstellt.

# Linear Function
def linear_function(x, m, b):
    return m * x + b

Eine lineare Funktion hat die Form f(x)=mx+bf(x) = mx + b, wobei mm die Steigung und bb den y-Achsenabschnitt bezeichnet. Es werden x-Werte von -20 bis 20 erzeugt und die Funktion mit beiden Achsen, einem Raster und markierten Schnittpunkten dargestellt.

1234567891011121314151617181920
import numpy as np import matplotlib.pyplot as plt def linear_function(x, m, b): return m * x + b x = np.linspace(-20, 20, 400) y = linear_function(x, m=2, b=-5) plt.plot(x, y, color='blue', linewidth=2, label="f(x) = 2x - 5") plt.scatter(0, -5, color='red', label="Y-Intercept") plt.scatter(2.5, 0, color='green', label="X-Intercept") plt.axhline(0, color='black', linewidth=1) plt.axvline(0, color='black', linewidth=1) plt.xlabel("x") plt.ylabel("f(x)") plt.grid(True, linestyle='--', alpha=0.6) plt.legend() plt.title("Linear Function: f(x) = 2x - 5") plt.show()
copy

Quadratische Funktion

Eine quadratische Funktion folgt f(x)=ax2+bx+cf(x) = ax^2 + bx + c und erzeugt eine parabolische Kurve. Wichtige Merkmale sind der Scheitelpunkt und die Nullstellen.

# Quadratic Function
def quadratic_function(x):
    return x**2 - 4*x - 2

Eine quadratische Funktion folgt f(x)=ax2+bx+cf(x) = ax^2 + bx + c und bildet eine Parabel. Wir erzeugen x-Werte von -2 bis 6, stellen die Funktion grafisch dar und markieren den Scheitelpunkt sowie die Schnittpunkte mit den Achsen. Die Darstellung enthält beide Achsen, ein Raster und Beschriftungen.

12345678910111213141516171819202122232425
import numpy as np import matplotlib.pyplot as plt def quadratic_function(x): return x**2 - 4*x - 2 x = np.linspace(-2, 6, 200) y = quadratic_function(x) plt.plot(x, y, color='blue', linewidth=2, label="f(x) = x² - 4x - 2") plt.scatter(2, quadratic_function(2), color='red', label="Vertex (2, -6)") plt.scatter(0, quadratic_function(0), color='green', label="Y-Intercept (0, -2)") # X-intercepts from quadratic formula x1, x2 = (4 + np.sqrt(24)) / 2, (4 - np.sqrt(24)) / 2 plt.scatter([x1, x2], [0, 0], color='orange', label="X-Intercepts") plt.axhline(0, color='black', linewidth=1) plt.axvline(0, color='black', linewidth=1) plt.xlabel("x") plt.ylabel("f(x)") plt.grid(True, linestyle='--', alpha=0.6) plt.legend() plt.title("Quadratic Function: f(x) = x² - 4x - 2") plt.show()
copy
question mark

Welcher Code definiert korrekt eine quadratische Funktion in Python, die (f(x) = x^2 - 4x - 2) berechnet?

Select the correct answer

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 1. Kapitel 5
some-alt