import matplotlib.pyplot as plt
import numpy as np
# Create x values ranging from 0 to 8
x = np.linspace(0, 8, 100)
# Define the function f(x) = -x + 2
# This satisfies f(4) = -2 and has a constant negative slope
y = -x + 2
# Create the plot
plt.figure(figsize=(8, 6))
plt.plot(x, y, label="f(x)", color='blue', linewidth=2)
# Plot the specific point (4, -2)
plt.scatter(4, -2, color='red', s=100, zorder=5, label="f(4) = -2")
# Add annotations to explain the conditions
plt.annotate('f\'(x) < 0 (Decreasing)', xy=(2, 0), xytext=(1, 2),
arrowprops=dict(facecolor='black', shrink=0.05))
plt.annotate('f\'(x) < 0 (Decreasing)', xy=(6, -4), xytext=(5.5, -1),
arrowprops=dict(facecolor='black', shrink=0.05))
plt.text(4.2, -1.8, "(4, -2)", fontsize=12, color='red')
# Set up the chart layout
plt.axhline(0, color='black', linewidth=1) # x-axis
plt.axvline(0, color='black', linewidth=1) # y-axis
plt.grid(True, linestyle='--', alpha=0.7)
plt.title("Graph satisfying: f(4)=-2 and f'(x) < 0 everywhere")
plt.xlabel("x")
plt.ylabel("f(x)")
plt.legend()
# Show the plot
plt.show()