import numpy as npimport matplotlib.pyplot as plt
def f(x):return 1/(x**2 - 1)
x = np.linspace(-5, 5, 1000)
y = f(x)
plt.figure(figsize=(10,6))plt.plot(x, y, label='f(x)=1/(x^2-1)')plt.axvline(x=1, color='r', linestyle='--', label='Vertical asymptote at x=1')plt.axvline(x=-1, color='y', linestyle='--', label='Vertical asymptote at x=-1')plt.xlabel('x')plt.ylabel('f(x)')plt.title('Graph of f(x)=1/(x^2-1)')plt.legend()plt.grid(True)plt.show()
import numpy as np
Define the function f(x)import matplotlib.pyplot as plt
def f(x):
Generate x valuesreturn 1/(x**2 - 1)
x = np.linspace(-5, 5, 1000)
Calculate y valuesy = f(x)
Create the plotplt.figure(figsize=(10,6))
plt.plot(x, y, label='f(x)=1/(x^2-1)')
plt.axvline(x=1, color='r', linestyle='--', label='Vertical asymptote at x=1')
plt.axvline(x=-1, color='y', linestyle='--', label='Vertical asymptote at x=-1')
plt.xlabel('x')
plt.ylabel('f(x)')
plt.title('Graph of f(x)=1/(x^2-1)')
plt.legend()
plt.grid(True)
plt.show()