# Jacobian for function including cubic spline

I am trying to fit a measured spectrum with a linear combination of end-member spectra which are approximated by cubic spline functions ($$f_1$$ and $$f_2$$). I also need to incorporate terms that account for a constant background, as well as inaccuracies in wavelength ($$\lambda$$). This last part makes the system non-linear: $$y_i = a\ f_1(m \lambda_i + c) + b\ f_2(m \lambda_i + c) + d$$ So I have a measured spectrum at multiple (>1000) wavelengths and am fitting the terms $$a$$, $$b$$, $$m$$, $$c$$ and $$d$$.

I'm trying to work out the Jacobian for this system, but am unsure where to start... the wavelength shift terms make it rather more complex than I know how to approach!

Any pointers for how to start this would be greatly appreciated!

$$\mathbf{J}_F(a, b, m, c, B_0) = \begin{bmatrix} \frac{\delta \lambda_0 A}{\delta a} & \frac{\delta \lambda_0 A}{\delta b} & \frac{\delta \lambda_0 A}{\delta m} & \frac{\delta \lambda_0 A}{\delta c} & \frac{\delta \lambda_0 A}{\delta B_0} \\ \vdots & \vdots & \vdots & \vdots & \vdots \\ \frac{\delta \lambda_n A}{\delta a} & \frac{\delta \lambda_n A}{\delta b} & \frac{\delta \lambda_n A}{\delta m} & \frac{\delta \lambda_n A}{\delta c} & \frac{\delta \lambda_n A}{\delta B_0} \\ \end{bmatrix} = \begin{bmatrix} f_I (\lambda_0 m + c) & f_{HI} (\lambda_0 m + c) & \lambda_0 a f_I'(\lambda_0 m + c) + \lambda_0 b f_{HI}'(\lambda_0 m + c) & a f_I'(\lambda_0 m + c) + b f_{HI}'(\lambda_0 m + c) & 1 \\ \vdots & \vdots & \vdots & \vdots & \vdots \\ f_I (\lambda_n m + c) & f_{HI} (\lambda_n m + c) & \lambda_N a f_I'(\lambda_n m + c) + \lambda_N b f_{HI}'(\lambda_0 m + c) & a f_I'(\lambda_N m + c) + b f_{HI}'(\lambda_n m + c) & 1 \\ \end{bmatrix}$$