![]() ![]() What constitutes a small timestep? Well, in order for interpolation to be accurate, the data needs to be smooth, and “quadratic-looking”. So quadratic interpolation in this case is a clear winner for small timesteps. The uninterpolated error has a quadratic dependency on the timestep Δt. So if I divide the timestep by 10, my error will decrease by a factor of around 1000. This makes sense: pretty much whenever you are using a polynomial method of degree \( n \), you will get an error that is a polynomial of degree \( n+1 \). Our interpolated error has a very clear cubic dependency on the timestep Δt. ![]() Plt.legend(('sampled','interpolated'), loc='best') Plt.loglog(dt_array, np.abs(err_array), '+', dt_array, np.abs(errq_array),'.') Print 'interpolated error ~= C * dt^m C=%f, m=%f' % (C,m) ![]() Print 'sampled error ~= C * dt^m C=%f, m=%f' % (C,m) Print '%d %.6f %.8f %g' % (k, delta_t, ymax_interp, errq) Ymax_interp, coeffs, imax, ymax = qinterp_max(y, extras=True) There’s not much to say about it if you have an x-coordinate \( x \) then the corresponding y-coordinate is \( y = y_1 + \frac \). You’ve probably heard of linear interpolation, where you are trying to find a point along the line containing the points \( (x_1, y_1) \) and \( (x_2, y_2) \). As a bonus, we’ll also look at a nifty root-finding method that uses quadratic interpolation as well. This algorithm uses quadratic interpolation, which has applications in the topic of root-finding and minimization. Today we will be drifting back into the topic of numerical methods, and look at an algorithm that takes in a series of discretely-sampled data points, and estimates the maximum value of the waveform they were sampled from.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |