Question: Solving an overdetermined system using LeastSquares with constraints

Hi, it seems I have an unusual situation and I have been unable to find a way to solve it. Hopefully someone can help. I have an overdetermined system; 14 equations, 4 unknowns. The unknowns are restricted to particular ranges (roughly 0 to 500). I first attempted to solve this the most direct way, by selecting 4 equations with the most "trustworthy" data, placing constraints on the solution variables using 'Assume', and then using Solve. The problem I encountered with this was that Solve repeatedly failed to come up with anything, and I'm quite certain this is because it had to use the exact numbers and there was no exact solution. I know my data is not exact and contains some unknowable amount of error, so I expected this would likely happen. It was suggested I use a Least-Squares approach and include all equations so that the system would be overdetermined and a solution would be a best fit. So I slapped the data into two matrices and used LinearAlgebra[LeastSquares] to pump out a solution. This worked in the sense that a solution was found, but the solution is entirely unphysical because there were no constraints placed on the solution. I cannot find a way to do this. Does anyone know of one? Here is the relevant code: A := Matrix(14,4): B := Matrix(14,1): s := Matrix(4,1): # The solution vector -- Can I place constraints on this and use it in the LA[LS] statement somehow? for i from 1 to 7 do for j from 1 to 2 do /* filling the matrices A and B with the data */ end do; end do; LinearAlgebra[LeastSquares](A,B);
Please Wait...