import numpy as np
import matplotlib.pyplot as plt
xs = np.linspace(-10, 10, 100)
coeffs = np.random.uniform(-5, 5, 5)
powers = [xs**4, xs**3, xs**2, xs**1, xs**0]
ys = np.dot(coeffs, powers)
def create_title(coeffs): # Ispisuje slučano generirane koeficijente u obliku f(x) = ax^4 + bx^3 + cx^2 + dx + e
return f"f(x) = {coeffs[0]}x^4{'+' if coeffs[1] > 0 else ''}{coeffs[1]}x^3{'+' if coeffs[2] > 0 else ''}{coeffs[2]}x^2{'+' if coeffs[3] > 0 else ''}{coeffs[3]}x{'+' if coeffs[4] > 0 else ''}{coeffs[4]}"
ax = plt.gca()
ax.plot(xs, ys)
ax.set_title(create_title(coeffs))
