Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using pycharm. Can't use numpy 3. (30 points) Write a function defined as: def interplD(x,xvals, yvals): x: a float or integer xvals: an array of

image text in transcribed

Using pycharm. Can't use numpy

3. (30 points) Write a function defined as: def interplD(x,xvals, yvals): x: a float or integer xvals: an array of floats or integers yvals: another array of floats or integers return value: the linearly interpolated value from yvals, based on the location of the x value within xvals. Note: the values in xvals will either be arranged from small to large, or they will be arranged from large to small. The will NOT be arranged randomly. You may NOT assume the x value is bounded between at least one pair of values in xvals. If the value of x cannot be located within xvals, then return the value of None (by saying return No. Do not extrapolate. The above note means that this interpID is different from the one you wrote for homework. To test the function, write and call the following main function: def mainO x1 array = [0.0, 0.1, 0.5, 1.8, 2.3, 4.7, 6.2] x2array = 19.2, 6.5, 4.7, 3.9, 2.2, 1.4, 0.5] yarray = [31, 5.2, 6.9, 4. 1, 3.5, 4.9, 6.4] anterpID(3.1, xlarray, yarray) print(vall) val2 interpID (5.2, x2array, yarray) print(val2) val3 = interp ID (0.3, x2array, x1 array) #this one should fail print(val3) main0 3. (30 points) Write a function defined as: def interplD(x,xvals, yvals): x: a float or integer xvals: an array of floats or integers yvals: another array of floats or integers return value: the linearly interpolated value from yvals, based on the location of the x value within xvals. Note: the values in xvals will either be arranged from small to large, or they will be arranged from large to small. The will NOT be arranged randomly. You may NOT assume the x value is bounded between at least one pair of values in xvals. If the value of x cannot be located within xvals, then return the value of None (by saying return No. Do not extrapolate. The above note means that this interpID is different from the one you wrote for homework. To test the function, write and call the following main function: def mainO x1 array = [0.0, 0.1, 0.5, 1.8, 2.3, 4.7, 6.2] x2array = 19.2, 6.5, 4.7, 3.9, 2.2, 1.4, 0.5] yarray = [31, 5.2, 6.9, 4. 1, 3.5, 4.9, 6.4] anterpID(3.1, xlarray, yarray) print(vall) val2 interpID (5.2, x2array, yarray) print(val2) val3 = interp ID (0.3, x2array, x1 array) #this one should fail print(val3) main0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions