FUNCTION REFERENCE

lsqlin

Solve linear least squares with linear constraints and bounds.

Solve linear least squares with linear constraints and bounds.

Syntax

[x, resnorm, residual, exitflag, output, lambda] = lsqlin(C, d, A, b, Aeq, beq, lb, ub, x0, options)

Syntax

x = lsqlin(problem)

Minimizes 0.5*||C*x-d||^2 for multiplier purposes. residual = C*x-d;

resnorm = residual'*residual. Uses the augmented residual QP: minimise

0.5*r'*r subject to C*x-r=d, with the shared primal-dual interior-point kernel.

Tall C is first reduced by Householder QR; residual and resnorm still use the

original C and d. Without constraints, an SVD solves the reduced or original

rectangular system directly. Does not form C'*C. Arguments after d can be omitted. Problem fields:

C,d,Aineq,bineq,Aeq,beq,lb,ub,x0,options. Bounds, output, options, limits and

lambda signs follow linprog; SciPy lsq_linear uses the same half-squared

objective, so its gradient and recovered multipliers need no factor of two.

For infeasible problems or failed solves without a finite feasible iterate,

x, resnorm and residual are []; all lambda fields are [].

SciPy signs: negate linprog ineqlin/eqlin/upper marginals; keep lower.

For SLSQP constraints -g >= 0 keep inequality multipliers; negate equality

multipliers for h = 0. All MatRust inequality multipliers are nonnegative.

Differences from MATLAB: dense real arrays only; auxiliary residuals count

toward the limits. Algorithm names are aliases. There is no simplex.

Example

[x,rn]=lsqlin(eye(2),[2;-1],[],[],[],[],[0;0],[1;1])

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.