my question following. have code computes, given x, value of function f(x). since f(x) bit large , complicated, , program has go through large dataset (x) @ different timesteps, not efficient. wondering if there function maybe in scipy, can create table different computed values f(x), save in file "function.txt" table (of course in case table larger going values 1e0, 1e8):
x f(x) 1 1 2 4 3 9 4 16 5 25
and somehow use interpolation, such if program reads x = 2.2 can estimate value f(x) calculated values in table.
you have polyfit , polyval in numpy :
import numpy np x=np.arange(1,6) y=np.array((1,4,9,16,25)) coeffs=np.polyfit(x,y,deg=5) # eval polynomial coefficients x2=np.linspace(np.min(x),np.max(x),1000) y2=np.polyval(coeffs,x2) # apply polynomial coeff broader set of data
Comments
Post a Comment