eps — Return floating-point spacing at one or at an input magnitude.
eps is a double constant; eps(), eps(x), eps(typename), and eps("like", p) are callable forms. The array form computes exact represented spacing rather than multiplying the magnitude by machine epsilon.
Syntax
d = eps()
d = eps(x)
d = eps(typename)
d = eps("like", prototype)Inputs
x- Type
NumericArray- Required
- Yes
- Default
- —
- Description
- Single- or double-precision real or complex input array.
typename- Type
StringScalar- Required
- Yes
- Default
- —
- Description
- Supported numeric class name.
like- Type
StringScalar- Required
- Yes
- Default
- —
- Description
- Like name-value keyword.
prototype- Type
LikePrototype- Required
- Yes
- Default
- —
- Description
- Prototype whose class, complexity, sparsity, and applicable residency are copied.
Returns
spacing- Type
Any- Description
- Real spacing scalar or same-shaped floating array, according to the input form.
Errors
RunMat:numericLimits:InvalidClass- When
- The requested class or prototype representation is not supported by the limit query.
- Message
numeric limit: unsupported class
RunMat:numericLimits:InvalidSyntax- When
- The arguments do not match a documented type-name or like-prototype form, or more than one output is requested.
- Message
numeric limit: invalid syntax
RunMat:numericLimits:Internal- When
- Constructing or placing the scalar result fails internally.
- Message
numeric limit: internal error
Represented spacing
Bare eps and eps() return the double-precision gap above one, exactly 2^-52. eps("single") returns the single-precision gap above one, exactly 2^-23.
The bare constant is a host double scalar obtained without array allocation, provider access, ambient services, or effects. Constant lookup has its own typed binding; it does not invoke the callable forms. Native and WASM consumers use the same constant value.
For a real or complex floating array x, eps(x) has the same shape and floating class as x and contains the positive spacing above each element's magnitude. The result is real and dense, including for complex or sparse input (implicit sparse zeros become positive subnormal spacings). Zero and subnormal magnitudes use the smallest positive subnormal spacing; Inf and NaN produce NaN. Integer and logical arrays are not accepted as value inputs.
eps("like", p) returns the spacing at one as a scalar matching the floating class, complexity, sparsity, and supported residency of p. It does not inspect the prototype's numeric contents.
Resident values
A supported real GPU input is evaluated on its owning provider and yields a resident output with the same shape and precision. The like form creates a resident scalar through protected provider upload. Unsupported resident classes or provider operations are rejected without silently downloading an explicitly resident input.
Examples
Read the constant
value = epsCompare double and single spacing
d = eps; s = eps('single'); disp(d); disp(s)Expected output:
d = 2.2204e-16
s = single(1.1921e-07)Measure spacing across binades
x = [0 1 2 -2]; d = eps(x); disp(d)Expected output:
d is a 1-by-4 double row vector of positive spacingsUsing eps with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how eps changes the result.
Run a small eps example, explain the result, then change one input and compare the output.
FAQ
What does eps(0) return?⌄
The smallest positive subnormal number of the input's floating class, not zero or the smallest normalized number.
Does the bare constant select GPU residency?⌄
No. Bare eps is a host scalar; ordinary numeric operations may subsequently consume or transfer it.
Related Math functions
Elementwise
abs · angle · besselj · bsxfun · complex · conj · double · erf · erfcinv · exp · expm1 · flintmax · gamma · gammaln · heaviside · hypot · imag · int16 · int32 · int64 · int8 · intmax · intmin · ldivide · log · log10 · log1p · log2 · minus · nextpow2 · plus · pow2 · power · rdivide · real · realmax · realmin · realsqrt · rescale · sign · single · sqrt · times · typecast · uint16 · uint32 · uint64 · uint8
Optim
acceptancesa · annealingboltz · annealingfast · coneprog · crossoverarithmetic · crossoverheuristic · crossoverintermediate · crossoverlaplace · crossoverscattered · crossoversinglepoint · crossovertwopoint · eqnproblem · EquationProblem.solve · EquationProblem.subsasgn · EquationProblem.subsref · evaluate · fgoalattain · fitscalingprop · fitscalingrank · fitscalingshiftlinear · fitscalingtop · fminbnd · fmincon · fminimax · fminsearch · fminunc · fseminf · fsolve · fzero · ga · gacreationlinearfeasible · gacreationnonlinearfeasible · gacreationsobol · gacreationuniform · gacreationuniformint · gaplotbestf · gaplotbestindiv · gaplotdistance · gaplotexpectation · gaplotgenealogy · gaplotmaxconstr · gaplotrange · gaplotscorediversity · gaplotscores · gaplotselection · gaplotstopping · integerConstraint · integral · intlinprog · linprog · lsqcurvefit · lsqlin · LsqlinWarmStart.subsasgn · LsqlinWarmStart.subsref · lsqnonlin · lsqnonneg · mutationadaptfeasible · mutationgaussian · mutationpositivebasis · mutationpower · mutationuniform · optimexpr · optimget · OptimizationConstraint.evaluate · OptimizationConstraint.subsasgn · OptimizationConstraint.subsref · OptimizationExitflag.double · OptimizationExitflag.eq · OptimizationExitflag.ne · OptimizationExitflag.string · OptimizationExpression.acos · OptimizationExpression.acosh · OptimizationExpression.acot · OptimizationExpression.acoth · OptimizationExpression.acsc · OptimizationExpression.acsch · OptimizationExpression.asec · OptimizationExpression.asech · OptimizationExpression.asin · OptimizationExpression.asinh · OptimizationExpression.atan · OptimizationExpression.atanh · OptimizationExpression.cat · OptimizationExpression.cos · OptimizationExpression.cosh · OptimizationExpression.cot · OptimizationExpression.coth · OptimizationExpression.csc · OptimizationExpression.csch · OptimizationExpression.ctranspose · OptimizationExpression.cumprod · OptimizationExpression.cumsum · OptimizationExpression.diag · OptimizationExpression.diff · OptimizationExpression.dot · OptimizationExpression.eq · OptimizationExpression.evaluate · OptimizationExpression.exp · OptimizationExpression.ge · OptimizationExpression.horzcat · OptimizationExpression.ldivide · OptimizationExpression.le · OptimizationExpression.log · OptimizationExpression.mean · OptimizationExpression.minus · OptimizationExpression.mldivide · OptimizationExpression.mpower · OptimizationExpression.mrdivide · OptimizationExpression.mtimes · OptimizationExpression.norm · OptimizationExpression.plus · OptimizationExpression.power · OptimizationExpression.prod · OptimizationExpression.rdivide · OptimizationExpression.reshape · OptimizationExpression.sec · OptimizationExpression.sech · OptimizationExpression.sin · OptimizationExpression.sinh · OptimizationExpression.sqrt · OptimizationExpression.subsasgn · OptimizationExpression.subsref · OptimizationExpression.sum · OptimizationExpression.tan · OptimizationExpression.tanh · OptimizationExpression.times · OptimizationExpression.trace · OptimizationExpression.transpose · OptimizationExpression.uminus · OptimizationExpression.uplus · OptimizationExpression.vertcat · OptimizationExpression.zeros · OptimizationExpression.zerosLike · OptimizationProblem.solve · OptimizationProblem.subsasgn · OptimizationProblem.subsref · OptimizationVariable.subsasgn · OptimizationVariable.subsref · optimoptions · optimplotconstrviolation · optimplotfirstorderopt · optimplotfunccount · optimplotfval · optimplotfvalconstr · optimplotmilp · optimplotstepsize · optimplotx · optimproblem · optimset · optimvar · optimwarmstart · particleswarm · patternsearch · psplotbestf · psplotbestx · psplotfuncount · psplotmaxconstr · psplotmeshsize · pswcreationuniform · pswplotbestf · quad · quadprog · QuadprogWarmStart.subsasgn · QuadprogWarmStart.subsref · saplotbestf · saplotbestx · saplotf · saplotstopping · saplottemperature · saplotx · savemilpsolutions · secondordercone · selectionremainder · selectionroulette · selectionstochunif · selectiontournament · selectionuniform · simulannealbnd · solve · surrogateopt · surrogateoptplot · temperatureboltz · temperatureexp · temperaturefast
Trigonometry
acos · acosd · acosh · acotd · acscd · asecd · asin · asind · asinh · atan · atan2 · atan2d · atand · 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
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
Ops
cross · ctranspose · dot · mldivide · mpower · mrdivide · mtimes · pagemtimes · pagetranspose · trace · transpose
Interpolation
griddedInterpolant · griddedInterpolant.subsref · interp1 · interp1q · interp2 · pchip · ppval · spline
Integer Division
Source you can read
Every RunMat function's source is public. Read exactly how eps is executed, line by line, in Rust.
- View the source for eps 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.