This is an improved version of my initial code.

To run the code:

Compile the code:

The interpolate() function will acept 3 parameters (n,instances,price)

You can invoke the function using parameter: interpolate(n,instances,price)

Or hardcoded values: interpolate(50,[1, 2, 50, 100, 500, 5000],[10, 2, 12, 16, 54.25, 1])