Find time lag between two time series
I have no good explanation for why this happens, except that perhaps quadratic signals are nonstationary in that their mean is changing (or unbounded).

If I do something to ensure the mean is bounded (and not changing) such as:

a = sin(t.^2);
b = sin((t-15).^2);


or

a = rem(a,100);
b = rem(b,100);


then I get the right answer: 15 samples.

This is what happens when I use the first:



This is what happens when I use the second:



both modified signals generate the same (correct) estimate of delay.

Scilab code to generate it below.  I also modified your zero padding etc. because it seems overly complicated.



Code Only Below

// 25867
t = [1:1000]; 
a = (t.^2); 
b = ((t-15).^2);
a = a - fix(a/200)*200; 
b = b - fix(b/ 200)*200;

c = [a zeros(1,length(b) - 1)];
d = [b zeros(1,length(a) - 1)];

mu = mean([mean(c) mean(d)])

c_fft = fft(c - mu); 
d_fft = fft(d - mu);

cross_spectral_density = c_fft.*conj(d_fft); 
cross_correlations = fftshift(ifft(cross_spectral_density));
xc = xcorr(c- mu,d- mu,length(t)-1);

[max_xcorr shift_idx] = max(abs(cross_correlations)); 
shift = shift_idx - max(length(a),length(b));

clf;
subplot(211);
plot(a);
plot(b,'r');
subplot(212)
plot(cross_correlations);
plot(xc,'g:')
plot(shift_idx,cross_correlations(shift_idx),'r.')
xtitle('Delay is ' + string(shift))