# Scipy Interpolate Gives Varying Results

## 06 April 2018 - 1 answer

I'm trying to get the same answer when reading of an interpolated function in Python using scipy.interpolate.interp1d but when I change the size of the x linspace I get different results.

Below is a simplified case where I feed the interpolated functions different radii and they return drastically different results. I can't work out why this is happening so any help would be greatly appreciated.

``````from scipy.interpolate import interp1d
import numpy as np
import matplotlib.pyplot as plt

plt.close('all')

M_centre = 2e30
G = 1.67e-11
m_test = 6e24

test_r = velocities_circ(50)
print(test_r)

test_r2 = velocities_circ2(50)
print(test_r2)

Out:
817312853.7629617
2584569596.664017
``````

I've thought about maybe the step size of the linspace is causing the varying reading on the interpolated function but it surely can't vary by an order of magnitude can it?

Edit: I have also tried this method using numpy.interp but it gives the same results as above.

Just a quick illustration of the problem with reduced numbers for contrast:

``````from scipy.interpolate import interp1d
import numpy as np
import matplotlib.pyplot as plt

M_centre = 2e30
G = 1.67e-11
m_test = 6e24

test_r1 = velocities_circ1(50)
print(test_r1)

test_r2 = velocities_circ2(50)
print(test_r2)