Implementierung von Identitäts-Quadratfunktionen in Python
Identitätsfunktion
Die Identitätsfunktion gibt den Eingabewert unverändert zurück und folgt der Form f(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)=x. Zur Visualisierung werden x-Werte von -10 bis 10 erzeugt, die Gerade geplottet, der Ursprung (0,0) markiert sowie Achsenbeschriftungen und Gitterlinien zur besseren Übersicht hinzugefügt.
12345678910111213141516171819202122232425import 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()
Konstante Funktion
Eine konstante Funktion liefert immer denselben Ausgabewert, unabhängig vom Eingabewert. Sie folgt der Gleichung f(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)=c. Zur Visualisierung werden x-Werte von -10 bis 10 erzeugt und eine horizontale Linie bei y=5 gezeichnet. Das Diagramm enthält Achsen, Beschriftungen und ein Raster zur besseren Übersicht.
123456789101112131415161718import 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()
Lineare Funktion
Eine lineare Funktion hat die Form f(x)=mx+b, wobei m die Steigung und b 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+b, wobei m die Steigung und b 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.
1234567891011121314151617181920import 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()
Quadratische Funktion
Eine quadratische Funktion folgt f(x)=ax2+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+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.
12345678910111213141516171819202122232425import 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()
Danke für Ihr Feedback!
Fragen Sie AI
Fragen Sie AI
Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen
Awesome!
Completion rate improved to 1.96
Implementierung 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)=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)=x. Zur Visualisierung werden x-Werte von -10 bis 10 erzeugt, die Gerade geplottet, der Ursprung (0,0) markiert sowie Achsenbeschriftungen und Gitterlinien zur besseren Übersicht hinzugefügt.
12345678910111213141516171819202122232425import 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()
Konstante Funktion
Eine konstante Funktion liefert immer denselben Ausgabewert, unabhängig vom Eingabewert. Sie folgt der Gleichung f(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)=c. Zur Visualisierung werden x-Werte von -10 bis 10 erzeugt und eine horizontale Linie bei y=5 gezeichnet. Das Diagramm enthält Achsen, Beschriftungen und ein Raster zur besseren Übersicht.
123456789101112131415161718import 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()
Lineare Funktion
Eine lineare Funktion hat die Form f(x)=mx+b, wobei m die Steigung und b 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+b, wobei m die Steigung und b 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.
1234567891011121314151617181920import 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()
Quadratische Funktion
Eine quadratische Funktion folgt f(x)=ax2+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+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.
12345678910111213141516171819202122232425import 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()
Danke für Ihr Feedback!