# How do I “push” matlab's lsqr solver to a particular solution?

The background to my problem can be found here: Iteratively solving a sparse, ill-conditioned system

I have a function that now works well. When I give it test data, I recover the expected result. However, when I give it real data, lsqr converges to a totally valid solution that is not the one I want.

Briefly: the solution should be the DFT of two bin-centered sinusoids in the presence of white noise. However, the solution I'm getting is one of the two sinusoids, white noise, but also multiple harmonics of those sinusoids, which are undesired.

The lsqr function allows me to supply a function handle to perform the A*x multiplication. Now I need to generate some kind of function that performs the matrix multiplication, but somehow pushes the algorithm away for test solutions with multiple tones.

How can I do this effectively? My first thought was to return a bogus result when the shape of the guess is not appropriate, but that seems like it might break the algorithm...

• Consider formulating as an optimization problem in which the objective function and/or constraints steer or force the solution to be the kind you want. I don;t understand your problem well enough (really at all) to suggest what such a formulation could or should be. depending on thr formulation and solution method, a good initial guess, as you other post says you have, might be very helpful. – Mark L. Stone May 3 '18 at 1:25
• Could you elaborate? That's certainly a possibility, and actually the first one I considered. I ended up using lsqr because it seemed easier than setting up matlab's optimizer. Both should, though, achieve the same goal, though. It was also a concern that my large data sets might be problematic. – Kayson May 3 '18 at 1:45
• As I wrote, i don;t understand your problem. But if for instance, if $Ax = b$ can be satisfied exactly, but the difficulty is that there are multiple solutions, not all of which are correct per other considerations, then make $Ax = b$ a constraint, and choose an objective function which rewards good solution and/or penalizes bad solution ( I ave no idea what that would be, but maybe you do). As for scale of problem, that's another matter. – Mark L. Stone May 3 '18 at 1:59
• Ok that makes sense, and I have a pretty good sense of how I would define an objective function. If you're familiar with matlab, do you suggest a particular solver and/or algorithm? – Kayson May 3 '18 at 2:05
• lsqr solves least squares problems, so it can only do quadratic regularizations. You want to regualrize for sparsity in the Fourier domain, which can be done with a 1-norm regularized solution. If you'd be willing to make some sample data available, I (and others) might be be able to provide you with a workable solution. – Brian Borchers May 3 '18 at 2:09