Untitled

mail@pastecode.io avatar
unknown
plain_text
5 months ago
1.1 kB
1
Indexable
import matplotlib.pyplot as plt
import numpy as np

# Define the function for the inequality
def f(x):
    return (x + 5) / (x + 3)

# Define the critical points
x1 = -5
x2 = -3

# Create a range of x values for plotting
x = np.linspace(-10, 2, 400)
y = f(x)

# Set up the plot
plt.figure(figsize=(8, 6))
plt.axhline(0, color='black', linewidth=1)
plt.axvline(x1, color='red', linestyle='--', label='x = -5')
plt.axvline(x2, color='red', linestyle='--', label='x = -3')
plt.plot(x, y, label=r'$\frac{x + 5}{x + 3}$')

# Shade the regions where the inequality is true
plt.fill_between(x, y, where=((x <= x1) | (x >= x2)), color='lightgreen', alpha=0.5, label='Solution Region')

# Mark the points -5 and -3
plt.scatter([x1, x2], [f(x1), f(x2)], color='red')
plt.text(x1, f(x1), '  (-5, 0)', verticalalignment='bottom')
plt.text(x2, f(x2), '  (-3, undefined)', verticalalignment='bottom')

# Plot details
plt.ylim(-10, 10)
plt.xlim(-10, 2)
plt.xlabel('x')
plt.ylabel(r'$\frac{x + 5}{x + 3}$')
plt.title('Graph of the Inequality $\\frac{x + 5}{x + 3} \\geq 0$')
plt.legend()
plt.grid(True)
plt.show()
Leave a Comment