Sunday, March 15, 2026

Some_Math

 Giving myself a little break, today, with a math problem that showed up on YouTube. 

It's a cubic polynomial, and although I think of myself as being able to handle these, I

found myself... well, a little rusty!

The problem: -k^3 + k^2 -12 = 0


Gemini Ai, to the rescue:

mathematics; help me solve the following cubic equation: -k^3 + k^2 -12 = 0. How many roots does it have, and how would I know?

                                                                                 








Python code for the graph:

import sympy as sp
import numpy as np
import matplotlib.pyplot as plt

k = sp.symbols('k')
equation = -k**3 + k**2 - 12

# Find roots
roots = sp.solve(equation, k)
print(f"Roots: {roots}")

# Calculate discriminant
# For ax^3 + bx^2 + cx + d = 0
a, b, c, d = -1, 1, 0, -12
discriminant = 18*a*b*c*d - 4*b**3*d + b**2*c**2 - 4*a*c**3 - 27*a**2*d**2
print(f"Discriminant: {discriminant}")

# Plotting the function to show the real root
k_vals = np.linspace(-4, 4, 400)
f_vals = [-val**3 + val**2 - 12 for val in k_vals]

plt.axhline(0, color='black', linewidth=1)
plt.axvline(0, color='black', linewidth=1)
plt.plot(k_vals, f_vals, label='f(k) = -k^3 + k^2 - 12')
plt.scatter([-2], [0], color='red', label='Real root (k=-2)')
plt.title('Plot of f(k) = -k^3 + k^2 - 12')
plt.xlabel('k')
plt.ylabel('f(k)')
plt.legend()
plt.grid(True)
plt.savefig('cubic_plot.png')
plt.show()















No comments: