Loading text...
Code Executed
Code:
import sympy as sp
x = sp.symbols('x')
f = sp.Abs(x**2 - 1)
area = sp.integrate(f, (x, -2, 2))
print(f"Total Area: {area}")
# Break down for steps
part1 = sp.integrate(x**2 - 1, (x, -2, -1))
part2 = sp.integrate(1 - x**2, (x, -1, 1))
part3 = sp.integrate(x**2 - 1, (x, 1, 2))
print(f"Part 1 (-2 to -1): {part1}")
print(f"Part 2 (-1 to 1): {part2}")
print(f"Part 3 (1 to 2): {part3}")
Output:
Total Area: 4 Part 1 (-2 to -1): 4/3 Part 2 (-1 to 1): 4/3 Part 3 (1 to 2): 4/3
STEP 1 • VERIFIED
Loading text...
VIEW STEPS
STEP 2 • VERIFIED
Loading text...
VIEW STEPS
STEP 3 • VERIFIED
Loading text...
VIEW STEPS
STEP 4 • VERIFIED
Loading text...
VIEW STEPS
Code Executed
Code:
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(-2.5, 2.5, 400)
y = np.abs(x**2 - 1)
plt.figure(figsize=(8, 5))
plt.plot(x, y, 'b-', label=r'$y = |x^2 - 1|$')
plt.axhline(0, color='black', linewidth=1)
plt.axvline(0, color='black', linewidth=1)
# Fill the area
x_fill = np.linspace(-2, 2, 400)
y_fill = np.abs(x_fill**2 - 1)
plt.fill_between(x_fill, y_fill, color='skyblue', alpha=0.4, label='Area = 4')
plt.title('Area under $y = |x^2 - 1|$ from $x = -2$ to $x = 2$')
plt.xlabel('x')
plt.ylabel('y')
plt.grid(True, linestyle='--', alpha=0.7)
plt.legend()
plt.xlim(-2.5, 2.5)
plt.ylim(0, 3.5)
plt.savefig('plot.png')
Output:
(No output)
Have a Math Question?
Ask your own question to get a step-by-step verified solution instantly.
Ask a Question