# Levenberg-marquardt: How to calculate the jacobian with fixed parameters

So I'm working on a fitting algorithm using the levenberg-marquardt algorithm and I'm a bit stumped as to how to handle fixed parameters. Looking around at other code, like the minpack version of the l-m algorithm, it looks like they are just setting the columns of the jacobian for fixed parameters to be 0.0, which makes sense as they are not changing. $J$ is being computed numerically and is working fine if there are not any fixed parameters.

The problem is that I always get a singular uninvertible matrix for $J^TJ$ when I do this, for example something like

[[       1005,          0,    -110500],
[          0,          0,          0],
[    -110500,          0,    3.013e7]]


(The 2nd parameter was held fixed in this case...)

Does anyone have some experience with the L-M algo? Any ideas as to how handle the fixed parameters in the jacobian? Should I just create a jacobian that only has the free parameters and patch in the fixed parameters somewhere down the line later?

-

2. Compute all of the elements of $F$ and $J$ but then remove those elements of $J$ corresponding to the fixed parameters. This allows you to write one routine for computing the Jacobian but then requires you to modify your LM routine so that you can specify which parameters are fixed. Once you've deleted columns from $J$ corresponding to the fixed parameters, you can compute $J^{T}J$ without the rows and columns of 0's that you've mentioned. However, the vector $\Delta p$ that you get back as a solution to the linear system will need to have 0's inserted in positions corresponding to the fixed parameters.
3. You could also modify the linear system of equations to force the solution to do what you want. If parameter $k$ is fixed, then zero out column $k$ and row $k$ of $J^{T}J$, then set the diagonal entry in row $k$, column $k$ to 1. Finally, make sure that the $k$th entry in the right hand side vector is 0. This will ensure that $\Delta p_{k}=0$.