function diff = platinum_offset(x,X,Y,n)
%this function calculates the difference between the fitting model and the
%resistance data
%x is a vector with two components
% A is the impurity resistance (with all the phonon freezed out)
% B is the Debye temperature
% X is the temperature
% Y is the measured resistance
% n is the number of terms you want to include in the Bloch-Greniesen
%   integral approximation
A = x(1);
B = x(2);
approx = 0;
y = B./X;

if nargin < 4
    n = 1;
end

for k=1:n
   medium = exp(-k.*y).*((y.^5)+(5/k)*(y.^4)+(20/k^2)*(y.^3)+(60/k^3)*(y.^2)+(120/k^4)*y + 120/k^5);
   approx = approx + medium; 
end

diff = A+1000/B*((X./B).^5).*(120*zeta(5)-approx)-Y;
