RunMat
  • Pricing
RunMat
GitHub
GitHub
Sign inTry in browser
DesktopRuntimePhysicsCADAdministrationAgent

Get RunMat updates

New releases, guides and examples.

Product+
  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download
Math+
  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting
Physics+
  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA
Industries+
  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance
Learn+
  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students
Compare+
  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons
Company+
  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms

Product

  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download

Math

  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting

Physics

  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA

Industries

  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance

Learn

  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students

Compare

  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons

Company

  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms
GitHubXLinkedIn

© Dystr, Inc. · RunMat v0.7.1, Nov 17, 2026

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.

/
See all docs
Builtin Reference
    • cross
    • ctranspose
    • dot
    • mldivide
    • mpower
    • mrdivide
    • mtimes
    • pagemtimes
    • pagetranspose
    • trace
    • transpose

mldivide — Solve linear systems with matrix left division.

mldivide(A, B) is the callable form of A \ B and solves A * X = B for scalar, square, rectangular, rank-deficient, complex, and supported provider-resident inputs.

Syntax

X = mldivide(A, B)

Inputs

A
Type
Any
Required
Yes
Description
Left numeric, logical, character, complex, or provider-resident operand.
B
Type
Any
Required
Yes
Description
Right numeric, logical, character, complex, or provider-resident operand.
NameTypeRequiredDefaultDescription
AAnyYes—Left numeric, logical, character, complex, or provider-resident operand.
BAnyYes—Right numeric, logical, character, complex, or provider-resident operand.

Returns

C
Type
NumericArray
Description
Matrix-arithmetic result.
NameTypeDescription
CNumericArrayMatrix-arithmetic result.

Errors

RunMat:mldivide:InvalidInput
When
Inputs are unsupported, are not matrices, or have incompatible dimensions.
Message
mldivide: unsupported operand types
RunMat:mldivide:Internal
When
The solver or acceleration provider cannot complete the operation correctly.
Message
mldivide: internal runtime failure
IdentifierWhenMessage
RunMat:mldivide:InvalidInputInputs are unsupported, are not matrices, or have incompatible dimensions.mldivide: unsupported operand types
RunMat:mldivide:InternalThe solver or acceleration provider cannot complete the operation correctly.mldivide: internal runtime failure

Left division

X = A \ B and mldivide(A, B) solve A * X = B. Dense square, rectangular, and rank-deficient inputs use a minimum-norm least-squares solve.

Both inputs must behave as matrices, with trailing singleton dimensions allowed. Nonscalar inputs must have the same number of rows.

Classes and scalar forms

A real pair returns a real floating result; a complex operand promotes the solve to complex arithmetic. Logical matrices are converted to double.

When A is scalar, A \ B scales B by 1/A. Fixed-width integers are supported only in this scalar-left form, where the integer class is preserved and division follows fixed-width rules. Integer matrix solving is rejected.

Sparse systems

On the host, nonsingular square CSC systems use direct triangular substitution when applicable and sparse LU otherwise. Rectangular and numerically singular CSC systems use column-pivoted Householder QR, followed by a complete orthogonal decomposition when needed, to return a minimum-norm least-squares solution. Zero-order systems preserve the solution shape. These routes borrow the coefficient matrix instead of converting it to dense storage. A dense right-hand side with the same real or complex single/double class preserves that class in the result; multiple right-hand sides share one factorization. Mixed-class sparse systems remain unsupported. Nonfinite input or a nonfinite numerical result returns an error.

Sparse factor fill, solve scratch, and final results support finite managed host allocation. Fill is admitted as it grows; a sparse input can still require substantial fill and may exceed the available budget. Triangular solves write directly into admitted result storage. QR uses native-precision factors and results, with scaled double-precision norm reductions. Numerical rank uses native machine epsilon times the larger matrix dimension times the initial largest column norm; an exactly zero matrix has rank zero. A second decomposition retains that selected rank rather than applying another tolerance. This is RunMat's minimum-norm and numerical-rank policy, not a promise of identical mixed-edge or rank decisions to MATLAB. Dense rectangular and rank-deficient inputs retain the minimum-norm SVD route.

Acceleration

A resident solve is offered to the exact provider that owns its inputs. Mixed-residency operands are uploaded only when their class and precision can be represented by that owner.

A typed unsupported-operation response permits host fallback. Provider failures, aliased outputs, wrong shapes, wrong types, and wrong owners are reported rather than treated as an unsupported optimization.

Examples

Solve a square system

A = [1 2; 3 4];
b = [5; 6];
x = A \ b

Expected output:

x = [-4; 4.5]

Solve an overdetermined system

A = [1 2; 3 4; 5 6];
b = [7; 8; 9];
x = A \ b

Expected output:

x = [-6; 6.5]

Scale by a scalar on the left

s = 2;
B = [2 4 6];
X = s \ B

Expected output:

X = [1 2 3]

Solve multiple right-hand sides

A = [4 1; 2 3];
B = eye(2);
X = A \ B

Expected output:

X = [0.3 -0.1; -0.2 0.4]

Solve a sparse system with two right-hand sides

A = sparse([0 2; 1 3]);
B = [10 -2; 19 -1];
X = A \ B

Expected output:

X = [4 2; 5 -1]

Solve a tall sparse least-squares system

A = sparse([1 0; 0 1; 1 1]);
b = [2; 3; 5];
x = A \ b

Expected output:

x = [2; 3]

Solve a wide sparse system with minimum norm

A = sparse([1 0 1; 0 1 1]);
b = [1; 1];
x = A \ b

Expected output:

x = [1/3; 1/3; 2/3]

Solve a rank-deficient sparse system

A = sparse([1 2; 2 4]);
b = [5; 10];
x = A \ b

Expected output:

x = [1; 2]

Solve a complex system

A = [2+i 1; -1 3-2i];
B = [1; 4+i];
X = A \ B;
R = A * X

Expected output:

R agrees with B

Using mldivide with coding agents

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

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

FAQ

Why must A and B have the same number of rows?⌄

The equation A * X = B requires each right-hand side to have one entry for every row of A.

What happens for singular or rectangular A?⌄

Dense inputs use a minimum-norm singular-value decomposition solve. Same-class host sparse inputs use rank-revealing QR and a complete orthogonal decomposition for minimum-norm least squares. Numerical rank follows the documented native-precision tolerance. MATLAB backslash does not generally promise the same minimum-norm choice for rectangular systems.

Are higher-dimensional arrays supported?⌄

Inputs must be effective matrices. Trailing singleton dimensions are allowed; reshape other arrays before solving.

How are logical and integer arrays treated?⌄

Logical matrices become double. Integer values are accepted only for scalar-left division and preserve the integer class.

Is backslash a callable alias?⌄

No. Use mldivide(A, B) or the A \ B operator.

Related Linalg functions

Ops

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

Structure

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

Factor

chol · decomposition · decomposition.ctranspose · decomposition.mldivide · decomposition.mrdivide · decomposition.mtimes · decomposition.rdivide · decomposition.subsref · decomposition.times · decomposition.uminus · decomposition.uplus · eig · eigs · gmres · ichol · ilu · lu · ordeig · ordqz · ordschur · pcg · qr · qz · rsf2csf · schur · svd

Solve

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

Source you can read

Every RunMat function's source is public. Read exactly how mldivide is executed, line by line, in Rust.

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

About RunMat

RunMat is a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/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
  • Left division
  • Classes and scalar forms
  • Sparse systems
  • Acceleration
  • Examples
  • Solve a square system
  • Solve an overdetermined system
  • Scale by a scalar on the left
  • Solve multiple right-hand sides
  • Solve a sparse system with two right-hand sides
  • Solve a tall sparse least-squares system
  • Solve a wide sparse system with minimum norm
  • Solve a rank-deficient sparse system
  • Solve a complex system
  • Using mldivide with coding agents
  • FAQ
  • Related Linalg functions
  • Ops
  • Structure
  • Factor
  • Solve
  • Source you can read
  • About RunMat