RunMat
  • Pricing
RunMat
GitHub
GitHub
DownloadSign InTry in Browser
DesktopRuntimeServer
RunMat

Run math blazing fast

GitHubX (Twitter)LinkedIn

Company

  • About
  • Pricing
  • Contact

Explore

  • RunMat for academia
  • RunMat vs MATLAB Online
  • Benchmarks

Get product updates and release notes from the RunMat team.

© 2026 Dystr · Made withfor the scientific community.

RunMat™ is a registered trademark of Dystr, Inc. MATLAB® is a registered trademark of The MathWorks, Inc. RunMat is not affiliated with, endorsed by, or sponsored by The MathWorks, Inc.

LicensePrivacy
/
See all docs
Builtin Reference
    • coneprog
    • fminbnd
    • fminunc
    • fsolve
    • fzero
    • integral
    • linprog
    • lsqcurvefit
    • lsqnonlin
    • optimoptions
    • optimset
    • quad
    • secondordercone

linprog — Solve linear programming minimization problems with inequality constraints, equality constraints, and bounds.

linprog minimizes f' * x subject to A*x <= b, Aeq*x == beq, and lb <= x <= ub. Supported forms are x = linprog(f,A,b), x = linprog(f,A,b,Aeq,beq), x = linprog(f,A,b,Aeq,beq,lb,ub), and the two-, three-, and four-output variants.

Syntax

x = linprog(f, A, b)
x = linprog(f, A, b, Aeq, beq)
x = linprog(f, A, b, Aeq, beq, lb, ub)
[x, fval] = linprog(f, A, b)
[x, fval] = linprog(f, A, b, Aeq, beq)
[x, fval] = linprog(f, A, b, Aeq, beq, lb, ub)
All supported linprog forms
x = linprog(f, A, b)
x = linprog(f, A, b, Aeq, beq)
x = linprog(f, A, b, Aeq, beq, lb, ub)
[x, fval] = linprog(f, A, b)
[x, fval] = linprog(f, A, b, Aeq, beq)
[x, fval] = linprog(f, A, b, Aeq, beq, lb, ub)
[x, fval, exitflag] = linprog(f, A, b)
[x, fval, exitflag] = linprog(f, A, b, Aeq, beq)
[x, fval, exitflag] = linprog(f, A, b, Aeq, beq, lb, ub)
[x, fval, exitflag, output] = linprog(f, A, b)
[x, fval, exitflag, output] = linprog(f, A, b, Aeq, beq)
[x, fval, exitflag, output] = linprog(f, A, b, Aeq, beq, lb, ub)

Inputs

NameTypeRequiredDefaultDescription
fNumericArrayYes—Linear objective vector.
ANumericArrayYes—Inequality constraint matrix.
bNumericArrayYes—Inequality constraint right-hand side.
AeqNumericArrayNo[]Equality constraint matrix.
beqNumericArrayNo[]Equality constraint right-hand side.
lbNumericArrayNo[]Lower bounds.
ubNumericArrayNo[]Upper bounds.

Returns

NameTypeDescription
xNumericArrayOptimal decision vector.
fvalNumericScalarObjective value f'*x at the solution.
exitflagNumericScalarSolver status code.
outputAnyDiagnostic metadata struct.

Returned values from linprog depend on how many outputs the caller requests.

Errors

IdentifierWhenMessage
RunMat:linprog:InvalidArgumentThe argument count or optional argument grammar is invalid.linprog: invalid argument
RunMat:linprog:InvalidInputObjective, constraint, or bound dimensions/types are invalid.linprog: invalid input

How linprog works

  • f, b, beq, lb, and ub must be numeric vectors with compatible lengths.
  • A and Aeq must be numeric matrices with one column per element of f.
  • [] may be passed for omitted optional Aeq, beq, lb, or ub arguments.
  • Typed-integer values in f, A, b, Aeq, beq, lb, or ub are role-specific RunMat extensions. Each value must be exactly representable as double before entering the host solver; otherwise the call errors instead of rounding silently.
  • Automatically resident inputs gather transparently for the host solver. Explicit gpuArray inputs are a RunMat extension and are rejected while strict compatibility mode disables extensions.
  • exitflag is 1 when an optimum is found, -2 when no feasible point is found, and -3 when the objective is unbounded below.
  • The fourth output is a struct with iterations, algorithm, constrviolation, and message fields.
  • Advanced MATLAB options, algorithms, problem structs, and lambda outputs are intentionally unsupported in this initial implementation.

Examples

Solve a bounded linear program

f = [-1; -2];
A = [1 1];
b = 4;
[x, fval, exitflag] = linprog(f, A, b, [], [], [0; 0], [])

Expected output:

x =
     0
     4
fval =
    -8
exitflag =
     1

Use equality constraints and lower bounds

f = [1; 2];
A = [];
b = [];
Aeq = [1 1];
beq = 3;
[x, fval] = linprog(f, A, b, Aeq, beq, [1; 0], [])

Expected output:

x =
     3
     0
fval =
     3

Use a finite lower bound on one variable

f = [1; 0];
[x, fval, exitflag] = linprog(f, [], [], [], [], [2; -Inf], [])

Expected output:

x =
     2
     0
fval =
     2
exitflag =
     1

Optimize along an equality face

f = [-1; 0; 0];
A = [1 0 0];
b = 1;
Aeq = [0 0 1];
beq = 0;
[x, fval, exitflag] = linprog(f, A, b, Aeq, beq, [], [])

Expected output:

x =
     1
     0
     0
fval =
    -1
exitflag =
     1

Inspect infeasible status

[x, fval, exitflag, output] = linprog(1, [], [], [], [], 2, 1);
exitflag

Expected output:

exitflag =
    -2

Using linprog with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how linprog changes the result.

Run a small linprog example, explain the result, then change one input and compare the output.

FAQ

Does linprog support optimoptions or MATLAB problem structs?⌄

No. This implementation supports the common positional numeric call forms only.

Does linprog run on the GPU?⌄

No. It gathers automatically resident inputs and runs the active-set solve on the host. Explicit gpuArray solver inputs are accepted only when RunMat extensions are enabled.

Can linprog accept integer arrays?⌄

Only as gated RunMat extensions, independently for each solver role. Every integer value must be exactly representable in binary64; outputs remain double precision.

Related Math functions

Optim

coneprog · fminbnd · fminunc · fsolve · fzero · integral · lsqcurvefit · lsqnonlin · optimoptions · optimset · quad · secondordercone

Elementwise

abs · angle · bsxfun · complex · conj · double · erf · erfcinv · exp · expm1 · factorial · flintmax · gamma · gammaln · heaviside · hypot · idivide · imag · intmax · intmin · ldivide · log · log10 · log1p · log2 · minus · nextpow2 · plus · pow2 · power · rdivide · real · realmax · realmin · realsqrt · rescale · sign · single · sqrt · swapbytes · times · typecast · uint16 · uint32 · uint8

Trigonometry

acos · acosh · asin · asinh · atan · atan2 · atanh · cos · cosd · cosh · cospi · deg2rad · pol2cart · rad2deg · sin · sind · sinh · sinpi · tan · tand · tanh

Reduction

all · any · bounds · cummax · cummin · cumprod · cumsum · cumtrapz · diff · gradient · max · maxk · mean · median · min · mink · movmax · movmean · movmedian · movmin · movprod · movstd · movsum · movvar · nnz · prod · rms · std · sum · trapz · var

Structure

bandwidth · isdiag · ishermitian · issymmetric · istril · istriu · symrcm

Signal

blackman · butter · buttord · cheb2ord · conv · conv2 · deconv · downsample · envelope · filter · filtfilt · fir1 · freqz · gauspuls · hamming · hann · hilbert · periodogram · pulstran · pwelch · rectpuls · resample · sawtooth · sinc · spectrogram · square · tripuls · unwrap · upsample · zplane

Rounding

ceil · fix · floor · mod · rem · round

Factor

chol · decomposition · eig · eigs · lu · qr · svd

Solve

cond · det · inv · linsolve · norm · null · pinv · rank · rcond · rref · vecnorm

Ops

cross · ctranspose · dot · mldivide · mpower · mrdivide · mtimes · pagemtimes · pagetranspose · trace · transpose

Symbolic

digits · int · limit · piecewise · sym · syms · vpa

Fft

fft · fft2 · fftn · fftshift · ifft · ifft2 · ifftn · ifftshift

Interpolation

griddedInterpolant · interp1 · interp1q · interp2 · pchip · ppval · spline

Discrete

lcm · primes

Ode

ode15s · ode23 · ode45

Poly

polyder · polyfit · polyint · polyval · roots

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how linprog is executed, line by line, in Rust.

  • View the source for linprog in Rust on GitHub
  • Learn how the RunMat runtime works
  • Found a bug? Open an issue with a minimal reproduction.

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.

Download RunMatOpen Sandbox
On this page
  • Syntax
  • Inputs
  • Returns
  • Errors
  • How linprog works
  • Examples
  • Solve a bounded linear program
  • Use equality constraints and lower bounds
  • Use a finite lower bound on one variable
  • Optimize along an equality face
  • Inspect infeasible status
  • Using linprog with coding agents
  • FAQ
  • Related Math functions
  • Optim
  • Elementwise
  • Trigonometry
  • Reduction
  • Structure
  • Signal
  • Rounding
  • Factor
  • Solve
  • Ops
  • Symbolic
  • Fft
  • Interpolation
  • Discrete
  • Ode
  • Poly
  • Open-source implementation
  • About RunMat