I’m using matplotlib. I have a list of 600 values. I also have an polynomial function that I’m graphing with values between 0 and 600. I’m trying to multiply every point by the corresponding value in the list.
I could evaluate the polynomial in a loop, and do the multiplication there, but I would end up with a graph of points instead of a line.
I think I might need to use the Transformations framework, but not sure how to apply it to the graph.
Edit:
a = [5, 2, 3 ... 0, 2, 8] # 600 values
poly_a = polyfit(a)
deriv_a = polyder(poly_a)
b = [232, 342 ... 346, 183] # 600 values
I need to multiply deriv_a by b.
I think you’re misunderstanding things a bit. This is what
numpyis for (if you’re usingmatplotlibit’s already converting things to a numpy array when you plot, regardless.)Just convert your “list of 600 values” to a numpy array and then evaluate the polynomial.
As an example:
Edit:
Based on your edit, it sounds like you’re asking how to use
numpy.polyder?Basically, you just want to use
numpy.polyvalto evaluate the polynomial returned bypolyderat your point locations.To build on the example above: