Rectistraight interpolation is a arrangement of computing the resemble estimate of a exercise in individual reasoning, consecrated merely specimens of the exercise at a fixed of subject-matters. This is commmerely verificationd where the estimates of a exercise are opposed or costly to accomplish. Control development, we may bear to raise extinguished a substantial examination, or a time-consuming simulation, to invent the exercise estimate control a consecrated reasoning. As an development, hold of “deformation of the mien wayfarer partition in a head-on concussion as a exercise of hurry” – to specimen the exercise control a consecrated hurry estimate, we may demand do a resonance examination!
Suppose we apprehend the exercise estimate at a fixed of subject-matters yi = f(xi), control i = 1…n. To resemble the exercise at a fantastic subject-matter x’, we invent the closest apprehendn subject-matters adown and overhead, say xadown < x’ and xoverhead > x’, induce a direct cord among (xbelow, ybelow) and (xabove, yabove), and conduct the estimate y’ where this cord is at x’.
The unconcealed controlm of the direct cord is a * x + b, where a = (yoverhead – ybelow) / (xoverhead – xbelow) and b = yadown – a * xbelow. Using this, we can calculate y’ = a * x’ + b
Your job is to utensil a exercise interpolate(x, y, x_test) that computes the cordar interpolation of the unpublic exercise f at a fantastic subject-matter x_test. The specimen is consecrated in the controlm of couple progressions x and y. Twain progressions bear the selfsimilar extension, and their elements are gum. The x progression contains the subject-matters where the exercise has been specimend, and the y progression contains the exercise estimate at the selfsimilar subject-matter. In other opinion, y[i] = f(x[i]).
Assumptions and restrictions:
You can wear that the reasonings are as feeling: that is, x and y are progressions, twain bear the selfsimilar extension, and their elements are gum.
You should NOT fashion any boldness abextinguished what fashion of progression the x and y reasonings are.
You can wear that the estimates in x are commanded in increasing command, and that they are rare (that is, there are no usual x-values).
You can wear that x_examination is a sum, and it is among couple estimates in the x progression, or maybe similar to a estimate in the progression. If x_examination is similar to a specimen estimate (a estimate in the input xsequence), your exercise should merely reappear the selfsimilar exercise estimate from y.
Your exercise must reappear a sum.
The scipy library has a all module, scipy.interlard which performs several kinds of interpolation, including cordar interpolation as feeling overhead. Obviously, you may referable verification this module, or any other module that provides a ready-made discerption to the problem, gone the intent of the assignment is control you to evince that you can utensil the exercise yourself. You can of race verification the scipy interpolation exercise as a relation to examination your utensilation.
NOTE: must be dindividual on python 3, using merely exercise definitions