Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The following data were collected by a company and represent discrete values of

ID: 3582039 • Letter: T

Question

The following data were collected by a company and represent discrete values of a function for which a specific formula is not known:

x

f(x)

1.1234 2.2468 3.3702 4.4936 5.617 6.7404 7.8638 8.9872 10.1106 11.234 12.3574 13.4808 14.6042 15.7276 16.851 17.9744 19.0978 20.2212 21.3446 22.468 23.5914 24.7148 25.8382 26.9616 28.085

167.56 137.6441 110.2523 85.38444 63.04068 43.22099 25.92535 11.15376 -1.093781 -10.81726 -18.01665 -22.69202 -24.84334 -24.47060 -21.57379 -16.15295 -8.208008 2.260895 15.25394 30.771 48.81213 69.37738 92.46655 118.0799 146.2172

Linear interpolation can be used to approximate the value of the function f (x) for any value of x as it falls between the smallest and largest value of x in the table. The procedure is the next:

We find the two values of x's of the table between which the value of x falls. These are called xi and xi + 1.

The corresponding values of f (xi) and f (xi + 1) are identified.

Interpolation between these values is performed to find the value of the function using the following

formula:

F (x) = f (xi) + ((F (xi + 1)) - f (xi)) / (x (i + 1)

Develop the program that calculates the approximation of the function for the following values of x's: -7.8, 13.65, 23.5914, and 33.8.

If the value of x is outside the range of values in the table, the program must send a message. Solve the problem using two one-dimensional arrays, one that stores the x's and another that stores the f (xi) 's.

Make programming for VBA using arrays

x

f(x)

1.1234 2.2468 3.3702 4.4936 5.617 6.7404 7.8638 8.9872 10.1106 11.234 12.3574 13.4808 14.6042 15.7276 16.851 17.9744 19.0978 20.2212 21.3446 22.468 23.5914 24.7148 25.8382 26.9616 28.085

167.56 137.6441 110.2523 85.38444 63.04068 43.22099 25.92535 11.15376 -1.093781 -10.81726 -18.01665 -22.69202 -24.84334 -24.47060 -21.57379 -16.15295 -8.208008 2.260895 15.25394 30.771 48.81213 69.37738 92.46655 118.0799 146.2172

Explanation / Answer

Please find below the program :

PROGRAM linint */VBA Script/*
integer index
real x(25), y(25),guess,z
data x / 1.123400, 2.246800, 3.370200, 4.493600, 5.61700,   */Data from the Company/*
: 6.740400, 7.863800, 8.987200, 10.11060, 11.23400,
: 12.35740, 13.48080, 14.60420, 15.72760, 16.85100,
: 17.97440, 19.09780, 20.22120, 21.34460, 22.46800,
: 23.59140, 24.71480, 25.83820, 26.96160, 28.08500/
data y / 167.5600, 137.6441, 110.2523, 85.38444, 63.04068,   */Data from the Company/*
: 43.22099, 25.92535, 11.15376, -1.093781, -10.81726,
: -18.01665, -22.69202, -24.84334, -24.47060, -21.57379,
: -16.15295, -8.208008, 2.260895, 15.25395, 30.77100,
: 48.81213, 69.37738, 92.46655, 118.0799, 146.2172 /

print *,'X-VALUE'
read *, Z
IF ((X .LT. X(1)) .OR. (X .GT. X(25)) THEN
PRINT *, 'OUT OF RANGE'
GOTO 1
ENDIF
DO 2 I=2,25
IF (X .LT. X(I)) THEN
INDEX = I-1
GOTO 3
ENDIF
CONTINUE
CONTINUE
guess=(y(index+1)-y(index))/(x(index+1)-x(index))
guess=y(index)+guess*(z-x(index))
print *,'INTERPOLATED VALUE Y( ', Z,' ) = ',guess
STOP
END
  

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote