Help with Gerschgorin circle root localisation
I need help with the Gerschgorin circles root localisation.
Consider the following function:
- $f = x^5 - 13 x^3 - x^2 + 10 x + 170$
Visualize the roots using Gerschgorin-Circle. Include a plot of the function itself, complete with labels and title, in your report in a SageMath Jupyter notebook.
from sympy import symbols, Poly, solve
from sympy.plotting import plot
# Define the function f and the variable x
x = symbols('x')
f = x**5 - 13*x**3 - x**2 + 10*x + 170
# Convert f to a polynomial
f_poly = Poly(f, x)
# Find all the roots
roots = solve(f_poly, domain='CC')
# Print all roots
print("All roots:")
for root in roots:
root_approx = root.evalf()
print(root_approx)
# Filter real and complex roots
real_roots = [root for root in roots if root.is_real]
complex_roots = [root for root in roots if not root.is_real]
# Print real roots
print("Real roots:")
for root in real_roots:
root_approx = root.evalf()
print(root_approx)
# Print complex roots
print("Complex roots:")
for root in complex_roots:
root_approx = root.evalf()
print(root_approx)
# Print the number of real roots
num_real_roots = len(real_roots)
print("Number of real roots:", num_real_roots)
# Plot the real part of the function f
p1 = plot(f, (x, -5, 5), title='Graph of f(x)', real=True)
This looks like homework.
Try to describe where you are stuck and to isolate what you need help with.