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.2, Nov 26, 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
    • poly
    • polyder
    • polyfit
    • polyint
    • polyval
    • roots

polyval — Evaluate a polynomial at numeric points and optionally compute prediction intervals.

polyval(p,x) evaluates descending-power coefficients by Horner's method at every element of x. Polyfit statistics S and scaling values mu enable centering-aware evaluation and prediction intervals.

Syntax

y = polyval(p, x)
y = polyval(p, x, S)
y = polyval(p, x, S, mu)
[y, delta] = polyval(p, x, S)
[y, delta] = polyval(p, x, S, mu)

Inputs

p
Type
Any
Required
Yes
Description
Descending-power coefficient vector.
x
Type
Any
Required
Yes
Description
Numeric evaluation points, of any shape.
S
Type
Any
Required
No
Description
Optional polyfit statistics structure; required for delta.
S
Type
Any
Required
No
Description
Polyfit statistics structure or [].
mu
Type
Any
Required
No
Description
Centering/scaling values; first two elements are mean and nonzero scale.
NameTypeRequiredDefaultDescription
pAnyYes—Descending-power coefficient vector.
xAnyYes—Numeric evaluation points, of any shape.
SAnyNo—Optional polyfit statistics structure; required for delta.
SAnyNo—Polyfit statistics structure or [].
muAnyNo—Centering/scaling values; first two elements are mean and nonzero scale.

Returns

y
Type
Any
Description
Evaluated polynomial values with X's shape.
delta
Type
Any
Description
Prediction interval values computed from S.
NameTypeDescription
yAnyEvaluated polynomial values with X's shape.
deltaAnyPrediction interval values computed from S.

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

Errors

RunMat:polyval:InvalidArgument
When
S/mu or requested-output combination is malformed.
Message
polyval: invalid argument
RunMat:polyval:InvalidInput
When
Coefficients or evaluation points cannot be interpreted as numeric input.
Message
polyval: invalid input
RunMat:polyval:Internal
When
Runtime fails while building values, deltas, or provider fallbacks.
Message
polyval: internal runtime failure
IdentifierWhenMessage
RunMat:polyval:InvalidArgumentS/mu or requested-output combination is malformed.polyval: invalid argument
RunMat:polyval:InvalidInputCoefficients or evaluation points cannot be interpreted as numeric input.polyval: invalid input
RunMat:polyval:InternalRuntime fails while building values, deltas, or provider fallbacks.polyval: internal runtime failure

Inputs and shape

Coefficients may be a scalar, empty vector, or any vector shape with at most one nonsingleton dimension. Numeric or logical points may be scalar, vector, matrix, or N-D; y follows x's shape. Empty points return empty output; empty coefficients represent the zero polynomial.

Logical values convert to double. Typed fixed-width integer coefficients, points, and numeric fit metadata are independent RunMat-mode extensions, checked for exact binary64 conversion before evaluation. Floating complex coefficients and points use complex host arithmetic.

polyval(p,x,[],mu) evaluates at (x-mu(1))/mu(2). The runtime uses the first two mu elements; both must be finite and the scale nonzero. A complex mu is admitted only when those elements have zero imaginary components.

Prediction intervals

[y,delta] = polyval(p,x,S) and the four-input form require nonempty polyfit statistics S with fields R, df, and normr. R must be square with one row per coefficient; df and normr are real scalars. Without S, requesting delta is an argument error, not a zero interval.

The interval uses the fit's QR factor in the same coordinate basis as p. For [p,S] = polyfit(...), pass S without mu; for [p,S,mu] = polyfit(...), pass both S and mu. If df is nonpositive or normr is zero, delta is zero. Further requested output slots are padded with scalar zero values.

Provider execution

A compatible real workload with resident coefficient or point input may use the owning provider's Horner hook. The current adapter first converts operands to host numerical vectors, then uploads provider-precision buffers for the hook; this is not zero-copy resident evaluation. Complex and prediction-interval routes execute on the host.

Real host results may be uploaded to preserve requested residency, while unsupported complex output remains host-resident. Provider output shape, storage, owner, and non-aliasing are validated before publication. Evaluation is a fusion boundary.

Examples

Evaluate at one point

p = [2 -3 5];
y = polyval(p,4)

Expected output:

y = 25

Evaluate across a vector

p = [1 0 -2 1];
x = linspace(-2,2,5);
y = polyval(p,x)

Expected output:

y = [-3 2 1 0 5]

Preserve a matrix of query points

[X,Y] = meshgrid(-1:1);
Z = polyval([1 -3 2],X+Y)

Expected output:

Z = [12 6 2; 6 2 0; 2 0 0]

Reuse polyfit centering and scaling

x = -2:2;
y0 = sin(x)+0.05*cos(3*x);
[p,S,mu] = polyfit(x,y0,3);
y = polyval(p,x,[],mu)

Expected output:

y is a smoothed fit with x's shape

Compute an interval from fit statistics

x = (0:10)';
[p,S,mu] = polyfit(x,exp(x/10),3);
[y,delta] = polyval(p,5,S,mu)

Expected output:

y is the fitted value; delta is its interval estimate

Evaluate with complex coefficients and points

p = [1+2i -3 4i];
z = [-1+1i 0 1-2i];
y = polyval(p,z)

Expected output:

y contains complex values

Evaluate a real polynomial with resident points

x = gpuArray(linspace(-1,1,2048));
p = [1 0 1];
y = polyval(p,x);
values = gather(y)

Expected output:

values = x.^2 + 1 on the host

Using polyval with coding agents

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

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

FAQ

Do coefficients need to be a row?⌄

No. A row, column, or singleton-extended vector is accepted. The result follows the shape of x.

Which point shapes are supported?⌄

Scalar, vector, matrix, and N-D numeric or logical point arrays are supported, including complex floating data.

How does mu affect evaluation?⌄

The first two mu values center and scale each point before Horner evaluation: (x-mu(1))/mu(2). The scale must be finite and nonzero.

Why does delta require S?⌄

The interval uses polyfit's QR factor R, degrees of freedom df, and residual norm normr; without these statistics it cannot be computed.

When is delta zero?⌄

When df is nonpositive or normr is zero, the current implementation returns a zero interval.

Can the result stay on a GPU?⌄

Supported real provider output stays resident. Complex output uses host arithmetic and may remain on the host.

Are sparse points supported?⌄

The current direct implementation accepts dense numeric and logical values, including supported provider tensors; sparse arrays are not a direct input form.

How is the polynomial evaluated?⌄

Horner's method nests multiplication and addition instead of computing each power separately.

How do I use polyval with polyfit?⌄

Fit [p,S,mu] = polyfit(x,y,n), then evaluate polyval(p,xfine,[],mu) or request [yf,delta] = polyval(p,xfine,S,mu) for intervals.

Related Math functions

Poly

poly · polyder · polyfit · polyint · roots

Elementwise

abs · angle · besselj · bsxfun · complex · conj · double · eps · 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

Bitwise

bitand · bitcmp · bitget · bitor · bitset · bitshift · bitxor · swapbytes

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 · 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

Ops

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

Symbolic

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

Discrete

factor · factorial · gcd · isprime · lcm · primes

Fft

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

Interpolation

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

Integer Division

idivide

Ode

ode15s · ode23 · ode45 · odeset

Source you can read

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

  • View the source for polyval 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
  • Inputs and shape
  • Prediction intervals
  • Provider execution
  • Examples
  • Evaluate at one point
  • Evaluate across a vector
  • Preserve a matrix of query points
  • Reuse polyfit centering and scaling
  • Compute an interval from fit statistics
  • Evaluate with complex coefficients and points
  • Evaluate a real polynomial with resident points
  • Using polyval with coding agents
  • FAQ
  • Related Math functions
  • Poly
  • Elementwise
  • Optim
  • Trigonometry
  • Reduction
  • Structure
  • Bitwise
  • Signal
  • Rounding
  • Factor
  • Solve
  • Ops
  • Symbolic
  • Discrete
  • Fft
  • Interpolation
  • Integer Division
  • Ode
  • Source you can read
  • About RunMat