I have a couple of functions defined like this (all parameters in a single array):
import numpy as np
def poly(x, params):
val = 0.
for i in range(len(params)):
val += params[-1 - i]*(x**i)
return val
a = 1.
b = 1.
c = 1.
params = [a, b, c]
Now I need to create the same function but without array as an argument of a function. I don't want to rewrite all my code, I need some new function for redefinition. The redefined function of my example should look like this:
def new_poly(x, a, b, c):
#take all parameters and put them back in an array to make the rest of the code work
params = [a, b, c]
val = 0.
for i in range(len(params)):
val += params[-1 - i]*(x**i)
return val
I will be grateful for any tips!