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

integral — Approximate finite scalar definite integrals in MATLAB and RunMat.

q = integral(fun, a, b) approximates the definite integral of fun from a to b using adaptive quadrature. Current support targets scalar-valued integrands over finite real bounds, following MATLAB-style call semantics.

Syntax

q = integral(fun, xmin, xmax)
q = integral(fun, xmin, xmax, options)
q = integral(fun, xmin, xmax, name, value, ...)

Inputs

NameTypeRequiredDefaultDescription
funAnyYes—Scalar integrand callback.
xminAnyYes—Lower integration bound.
xmaxAnyYes—Upper integration bound.
optionsAnyNo—Options struct for AbsTol/RelTol/MaxFunEvals.
namePropertyNameNo—Option name.
valuePropertyValueVariadic—Option value and additional name/value pairs.

Returns

NameTypeDescription
qNumericScalarNumerical integral estimate.

Errors

IdentifierWhenMessage
RunMat:integral:InvalidArgumentOption grammar/name-value parsing is invalid.integral: invalid argument
RunMat:integral:InvalidInputBounds/integrand/adaptive solver semantics are invalid.integral: invalid input

How integral works

  • The function may be a named function handle such as @sin, an anonymous function such as @(x) x.^2, or a function-handle string.
  • The integration loop evaluates the integrand at scalar sample points and adapts subintervals using Simpson error estimates.
  • The integrand must return a finite real scalar. Array-valued and complex-valued integrands are not supported yet.
  • Finite reversed bounds are accepted and negate the result. Equal bounds return zero.
  • AbsTol, RelTol, and MaxFunEvals name/value options are accepted for the initial scalar implementation.

Examples

Integrate a polynomial anonymous function

q = integral(@(x) x.^2, 0, 1)

Expected output:

q =
    0.3333

Integrate sine over one half-period

q = integral(@sin, 0, pi)

Expected output:

q =
    2.0000

Set tighter tolerances

q = integral(@sin, 0, pi, 'AbsTol', 1e-12, 'RelTol', 1e-8)

Expected output:

q =
    2.0000

Using integral with coding agents

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

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

FAQ

Is this the same as trapz?⌄

No. integral evaluates a function handle adaptively over continuous bounds. trapz integrates already-sampled discrete data.

Does integral support vector-valued functions?⌄

Not yet. The initial implementation supports finite real scalar-valued integrands.

Does integral run on the GPU?⌄

The adaptive solver runs on the host because it repeatedly invokes user code through function-handle dispatch. The callback itself may call GPU-aware builtins.

Related Math functions

Optim

coneprog · fminbnd · fminunc · fsolve · fzero · linprog · 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 integral is executed, line by line, in Rust.

  • View the source for integral 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 integral works
  • Examples
  • Integrate a polynomial anonymous function
  • Integrate sine over one half-period
  • Set tighter tolerances
  • Using integral 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