WOLFRAM

Enable JavaScript to interact with content and submit forms on Wolfram websites. Learn how
Wolfram Language & System Documentation Center

PolynomialModel []

represents a polynomial function with unknown degree.

PolynomialModel [n]

represents a polynomial function of a given degree n in the input variables.

PolynomialModel [n,vars]

uses an explicit variable specification vars.

PolynomialModel [n,pars,vars]

uses the provided coefficients pars.

Details
Details and Options Details and Options
Examples  
Basic Examples  
Scope  
Hyperparameters  
Degree  
Variables  
Parameters  
Evaluation  
Information  
Fitting  
Applications  
Basic Applications  
Data Modeling  
Identifying Resistance from Linear Response Data  
Model a Car's Stopping Distance  
Dose-Response Relationships  
Car Fuel Economy  
Interpolation and Extrapolation  
Possible Issues  
Interactive Examples  
See Also
Related Guides
History
Cite this Page

PolynomialModel []

represents a polynomial function with unknown degree.

PolynomialModel [n]

represents a polynomial function of a given degree n in the input variables.

PolynomialModel [n,vars]

uses an explicit variable specification vars.

PolynomialModel [n,pars,vars]

uses the provided coefficients pars.

Details

  • PolynomialModel represents a polynomial in the given variables in a format suitable for symbolic or numerical evaluation and fitting.
  • Polynomials are often used to fit smooth nonlinear phenomena such as sensor calibration curves, braking distance with speed, material stressstrain responses and gradual environmental and economic trends over a limited range.
  • The univariate polynomial of degree n is given by sum _(i=0)^(n)TemplateBox[{i}, CTraditional] x^i.
  • The multivariate polynomial of total degree n is given by sum_(i=0)^nsum_(j_1+...+j_k⩵i) c_(j_1,...,j_k)TemplateBox[{{x, _, 1}, {j, _, 1}}, Superscript] TemplateBox[{{..., , {x, _, k}}, {j, _, k}}, Superscript].
  • Individual monomials are sorted successively by total degree, max degree and finally, variable order.
  • When used in ModelFit , each monomial is used as an independent basis element.
  • The current model representation can be expanded using PolynomialModel [][{x1,}].
  • Hyperparameters
  • The following hyperparameters may be specified for this model:
  • "Degree" Automatic polynomial degree
  • Possible settings for degree include:
  • n degree n
    UpTo [n] all degrees up to and including n
    n;;m all degrees between n and m inclusive
    n;;m;;s all degrees between n and m in steps of s
  • A limited subset of models may be expressed as PolynomialModel [UpTo [n]].
  • Variables
  • When not specified, variables will automatically be enumerated using x [i].
  • Valid variable specifications vars include:
  • n the number of variables
    symb a symbolic representation of a single variable
    {symb1,} a list of symbolic variables
  • Parameters
  • When not specified, parameters will automatically be enumerated using C [i].
  • Valid parameter pars specifications in the form {par1,} include:
  • val a fixed parameter value val
    par a symbolic parameter name par
    parval a symbolic name par set to a fixed value val
  • Properties
  • Model properties can be extracted using Information [PowerModel[],prop].
  • Valid basic properties include:
  • "BaseType" model base type
    "Name" model name
    "ShortName" short identifier to use as label
    "InputType" supported input types
    "OutputType" supported output types
  • Valid data-related properties include:
  • "ColumnNames" names of the input features
    "ColumnVariableMap" map between column names and model variables
    "InputSize" dimensionality of the input
    "OutputSize" dimensionality of the output
    "Trainable" whether the model is fully specified and can be trained
    "Trained" whether the model can be evaluated numerically
    "VariableColumnMap" map between model variables and column names
    "Variables" name of the model variables
  • Best model-related properties include:
  • "Expression" model expression
    "Function" model as a pure function
    "SymbolicExpression" model expression with symbolic parameters
    "TabularFunction" pure function suitable to work on a tabular row
  • Parameter-related properties include:
  • "ParameterAssociation" association of parameter names and values
    "ParameterCount" the number of parameters
    "ParameterInitialValues" initial values for the fit
    "ParameterNames" parameter names
    "ParameterRules" list of rules with parameter names and values
    "Parameters" parameter values if present; names otherwise
    "ParameterValues" parameter values
    "Constraints" parameter constraints
  • Hyperparameter-related properties include:
  • "HyperparameterDefaultDomain" default hyperparameter search domain
    "HyperparameterDomain" specified hyperparameter search domain
    "Hyperparameters" hyperparameter values

Examples

open all close all

Basic Examples  (3)

Specify a quadratic polynomial model:

Wolfram Language code: PolynomialModel[2]

Use an explicit input size and custom names for the symbolic parameters:

Wolfram Language code: PolynomialModel[2, {a, b, c}, 1]

Plot over a variety of degrees using constant parameters:

Wolfram Language code: Plot[{PolynomialModel[1, {1, 1}, 1][x], PolynomialModel[2, {1, 1, 1 }, 1][x], PolynomialModel[3, {1, 1, 1, 1}, 1][x]}, {x, -2, 2}]

Scope  (24)

Hyperparameters  (2)

Degree  (2)

Specify the degree of the model:

Wolfram Language code: PolynomialModel[2][x]

Specify a family of models with the maximum given degree:

Wolfram Language code: model = PolynomialModel[UpTo[4]]

Use ModelFit to find the best polynomial model up to this maximum degree:

Wolfram Language code: ModelFit[1 + Range[10] ^ 2, model]

Variables  (2)

Specify a PolynomialModel by degree alone:

Wolfram Language code: PolynomialModel[2]

The number of variables is inferred from the arguments:

Wolfram Language code: PolynomialModel[2][{x}] PolynomialModel[2][{x, y, z}]

ModelFit will assume the number of variables is one less than the number of data points:

Wolfram Language code: ModelFit[{{1, 9, 55}, {1, 1, 7}, {1, 4, 25}, {8, 9, 118}, {8, 10, 124}, {8, 5, 94}}, PolynomialModel[2]]

Specify the number of variables:

Wolfram Language code: PolynomialModel[2, 2]

Give the variables a custom symbolic representation:

Wolfram Language code: PolynomialModel[2, {var1, var2}]

These names are overwritten when the model is evaluated symbolically:

Wolfram Language code: PolynomialModel[2, {var1, var2}][{a, b}]

Parameters  (4)

Parameter names are assigned automatically:

Wolfram Language code: PolynomialModel[2, 1]

Specify custom parameter names:

Wolfram Language code: PolynomialModel[2, {a, b, c}, 1]

Set a parameter to a specific value:

Wolfram Language code: PolynomialModel[2, {42, b, c}, 1]

Specify both parameter names and values:

Wolfram Language code: PolynomialModel[2, {a -> 1, b, c}, 1]

Evaluation  (5)

Symbolically evaluate a single-variable model:

Wolfram Language code: PolynomialModel[2, 1][x]

Symbolically evaluate a two-variable model:

Wolfram Language code: PolynomialModel[2, 2][{x, y}]

The number of variables is automatically inferred if not specified:

Wolfram Language code: PolynomialModel[2][x]
Wolfram Language code: PolynomialModel[2][{x, y}]

Evaluate the model on multiple symbolic variables:

Wolfram Language code: PolynomialModel[2, 2][{{x, y}, {a, b}}]

Evaluate the model on a list of points:

Wolfram Language code: PolynomialModel[2, 1][{1, 2, 3}]

Information  (5)

View general information about a model:

Wolfram Language code: Information[PolynomialModel[2]]

Some information is only available when variables or parameters are fully specified:

Wolfram Language code: Information[PolynomialModel[2, x]]

Extract a single property:

Wolfram Language code: Information[PolynomialModel[2, {a, b, c}, {x}], "Variables"]

Retrieve multiple properties:

Wolfram Language code: Information[PolynomialModel[2, {a, b, c}, x], {"Variables", "Parameters"}]

Get information about the default model values:

Wolfram Language code: Information[PolynomialModel[2, 1], {"Variables", "Parameters"}]

Fitting  (6)

Fit a polynomial model of the specified degree:

Wolfram Language code: ModelFit[{...}, PolynomialModel[3]]

Fit multiple degrees at once:

Wolfram Language code: ModelFit[{...}, PolynomialModel[UpTo[5]]]

Automatically detect the degree:

Wolfram Language code: ModelFit[{...}, PolynomialModel[]]

View the report to compare the fits:

Wolfram Language code: ModelFit[{...}, PolynomialModel[], "Report"]

Numerical parameter values are considered fixed during fitting:

Wolfram Language code: ModelFit[{...}, PolynomialModel[1, {1, b}, 1]]

Fixing all the parameters will result in a model equivalent to the input:

Wolfram Language code: Information[ModelFit[{...}, PolynomialModel[1, {1, 2}, 1]], "ParameterValues"]

Compare the performance of a previously trained model with one trained on the actual data:

Wolfram Language code: report = ModelFit[{...}, {PolynomialModel[2, {1, 2, 3}, 1], PolynomialModel[1]}, "Report"]

Extract the parameters for both models:

Wolfram Language code: report["ParameterValues" -> All]

Applications  (11)

Basic Applications  (6)

Fit the area of a rectangle to its width and height:

Wolfram Language code: ModelFit[Tabular[Association["RawSchema" -> Association["ColumnProperties" -> Association["Width" -> Association["ElementType" -> "Integer64"], "Height" -> Association["ElementType" -> "Integer64"], "Volume" -> Association["ElementType" -> "Integer64"]], "KeyColumns" -> None, "Backend" -> "WolframKernel"], "Options" -> {}, "BackendData" -> Association["ColumnData" -> DataStructure["ColumnTable", {{TabularColumn[Association["Data" -> {{5, 2, 1, 1, 10, 2, 5, 5, 10, 5}, {}, None}, "ElementType" -> "Integer64"]], TabularColumn[Association[ "Data" -> {{1, 1, 10, 5, 10, 5, 10, 2, 2, 5}, {}, None}, "ElementType" -> "Integer64"]], TabularColumn[Association["Data" -> {{5, 2, 10, 5, 100, 10, 50, 10, 20, 25}, {}, None}, "ElementType" -> "Integer64"]]}}]]]], PolynomialModel[]]

Fit the volume of water in a cuboid to its dimensions:

Wolfram Language code: ModelFit[Tabular[Association["RawSchema" -> Association["ColumnProperties" -> Association["Width" -> Association["ElementType" -> "Integer64"], "Height" -> Association["ElementType" -> "Integer64"], "Length" -> Association["ElementType" -> "Integer64"], "Volume" -> Association["ElementType" -> "Integer64"]], "KeyColumns" -> None, "Backend" -> "WolframKernel"], "Options" -> {}, "BackendData" -> Association["ColumnData" -> DataStructure["ColumnTable", {{TabularColumn[Association["Data" -> {{2, 2, 50, 15, 5, 5, 25, 50, 1, 5, 5, 15, 25, 25, 20, 25, 25, 20, 25, 2}, {}, None}, "ElementType" -> "Integer64"]], TabularColumn[Association["Data" -> {{15, 50, 20, 10, 5, 1, 20, 5, 20, 10, 20, 5, 1, 10, 20, 20, 5, 20, 2, 15}, {}, None}, "ElementType" -> "Integer64"]], TabularColumn[Association["Data" -> {{25, 50, 50, 20, 20, 5, 15, 50, 2, 15, 1, 20, 1, 15, 2, 1, 50, 20, 15, 5}, {}, None}, "ElementType" -> "Integer64"]], TabularColumn[Association["Data" -> {{750, 5000, 50000, 3000, 500, 25, 7500, 12500, 40, 750, 100, 1500, 25, 3750, 800, 500, 6250, 8000, 750, 150}, {}, None}, "ElementType" -> "Integer64"]]}}]]]], PolynomialModel[]]

Fit the area of a disc to its radius:

Wolfram Language code: ModelFit[Tabular[Association["RawSchema" -> Association["ColumnProperties" -> Association["Radius" -> Association["ElementType" -> "Integer64"], "Area" -> Association["ElementType" -> "Real64"]], "KeyColumns" -> None, "Backend" -> "WolframKernel"], "Options" -> {}, "BackendData" -> Association["ColumnData" -> DataStructure["ColumnTable", {{TabularColumn[Association["Data" -> {{1, 2, 5, 10, 15, 20, 25, 50}, {}, None}, "ElementType" -> "Integer64"]], TabularColumn[Association[ "Data" -> {{3.141592653589793, 12.566370614359172, 78.53981633974483, 314.1592653589793, 706.8583470577034, 1256.6370614359173, 1963.4954084936207, 7853.981633974483}, {}, None}, "ElementType" -> "Real64"]]}}]]]], PolynomialModel[]]

Compare with the geometrical solution:

Wolfram Language code: Area[Disk[{x, y}, r]]

Fit the volume of water in balls of different radii:

Wolfram Language code: ModelFit[Tabular[Association["RawSchema" -> Association["ColumnProperties" -> Association["Radius" -> Association["ElementType" -> "Integer64"], "Volume" -> Association["ElementType" -> "Real64"]], "KeyColumns" -> None, "Backend" -> "WolframKernel"], "Options" -> {}, "BackendData" -> Association["ColumnData" -> DataStructure["ColumnTable", {{TabularColumn[Association["Data" -> {{1, 2, 5, 10, 15, 20, 25, 50}, {}, None}, "ElementType" -> "Integer64"]], TabularColumn[Association[ "Data" -> {{4.1887902047863905, 33.510321638291124, 523.5987755982989, 4188.790204786391, 14137.16694115407, 33510.32163829113, 65449.84694978735, 523598.7755982988}, {}, None}, "ElementType" -> "Real64"]]}}]]]], PolynomialModel[]]

Compare with the geometrical solution:

Wolfram Language code: Volume[Ball[{0, 0, 0}, r]]

Fit a polynomial to the potential difference across a resistor under a controlled current:

Wolfram Language code: model = ModelFit[Tabular[Association["RawSchema" -> Association["ColumnProperties" -> Association["I" -> Association["ElementType" -> "Real64"], "V" -> Association["ElementType" -> "Real64"]], "KeyColumns" -> None, "Backend" -> "WolframKernel"], "Options" -> {}, "BackendData" -> Association["ColumnData" -> DataStructure["ColumnTable", {{TabularColumn[Association["Data" -> {{0.65, 5.41, 10.26, 13.790000000000001, 20.66, 23.76, 30.11, 34.95, 40.56, 43.74, 49.94, 56.38, 60.88, 65.8, 70.75}, {}, None}, "ElementType" -> "Real64"]], TabularColumn[Association[ "Data" -> {{0.02006172839506173, 0.16697530864197532, 0.31666666666666665, 0.4256172839506173, 0.6376543209876544, 0.7333333333333334, 0.929320987654321, 1.078703703703704, 1.251851851851852, 1.35, 1.541358024691358, 1.7401234567901236, 1.8790123456790124, 2.0308641975308643, 2.183641975308642}, {}, None}, "ElementType" -> "Real64"]]}}]]]], PolynomialModel[1, {0, rInv}, i]]

Calculate the resistance using :

Wolfram Language code: 1 / Information[model, "ParameterAssociation"][rInv]

Fit a polynomial model to the distance a car travels at constant acceleration:

Wolfram Language code: model = ModelFit[Tabular[Association["RawSchema" -> Association["ColumnProperties" -> Association["Time" -> Association["ElementType" -> TypeSpecifier["Quantity"]["Real64", "Seconds"]], "Distance" -> Association["ElementType" -> TypeSpecifier["Quantity"][ "Real64", "Meters"]]], "KeyColumns" -> None, "Backend" -> "WolframKernel"], "Options" -> {}, "BackendData" -> Association["ColumnData" -> DataStructure["ColumnTable", {{TabularColumn[Association["Data" -> {5, {{{15.06182208600146, 16.873830425026103, 17.432462695686873, 17.63412877857748, 19.55887871075077}, {}, None}}, None}, "ElementType" -> TypeSpecifier["Quantity"]["Real64", "Seconds"], "CachedOriginalExpression" -> {Quantity[15.06182208600146, "Seconds"], Quantity[16.873830425026103, "Seconds"], Quantity[17.432462695686873, "Seconds"], Quantity[17.63412877857748, "Seconds"], Quantity[19.55887871075077, "Seconds"]}]], TabularColumn[Association["Data" -> {5, {{{338.5761193813797, 406.0620070137123, 428.0263142518381, 436.0895831977932, 516.6285913791094}, {}, None}}, None}, "ElementType" -> TypeSpecifier["Quantity"]["Real64", "Meters"], "CachedOriginalExpression" -> {Quantity[338.5761193813797, "Meters"], Quantity[406.0620070137123, "Meters"], Quantity[428.0263142518381, "Meters"], Quantity[436.0895831977932, "Meters"], Quantity[516.6285913791094, "Meters"]}]]}}]]]], PolynomialModel[2, {x0, v0, a2}, t]]

Compare to the formula and extract the coefficients to estimate the initial velocity and acceleration :

Wolfram Language code: Information[model, "ParameterAssociation"]

Data Modeling  (4)

Identifying Resistance from Linear Response Data  (1)

Measure the change in potential difference with a set current across a resistor:

Wolfram Language code: data = Tabular[...]
Wolfram Language code: ColumnKeys[data]

Fit a linear relationship:

Wolfram Language code: model = ModelFit[data, PolynomialModel[1]]

Compare the model to the fit:

Wolfram Language code: ListPlot[data -> {"Current", "Voltage (measured)"}, PlotFit -> model, ...]

The constant term corresponds to the absolute uncertainty in the system and the gradient to the resistance of the resistor:

Wolfram Language code: Information[model, "Parameters"]

Model a Car's Stopping Distance  (1)

Retrieve data on the stopping distances of an assortment of cars:

Wolfram Language code: stoppingDistance = ToTabular@ResourceData["Sample Data: Car Stopping Distances"]

Fit a polynomial model:

Wolfram Language code: model = ModelFit[stoppingDistance -> {"Speed", "Distance"}, PolynomialModel[]]

Inspect the model performance:

Wolfram Language code: Plot[model[Quantity[x, "Miles" / "Hours"]], {x, 0, 25}]

This implies the car would go backward when trying to stop at under 5 mph. The stopping distance at 0 mph should be 0 ft, therefore set the intercept to zero:

Wolfram Language code: model0 = ModelFit[stoppingDistance, {PolynomialModel[1, {0, k}, 1]}]

Compare the two fits to the data:

Wolfram Language code: Show[ ListPlot[stoppingDistance -> {"Speed", "Distance"}, ...], Plot[{model[x], model0[x]}, {x, Quantity[0, "Miles"/"Hours"], Quantity[25, "Miles"/"Hours"]}]]

Dose-Response Relationships  (1)

Retrieve data on a small example dose-response dataset:

Wolfram Language code: growth = GroupBy[Tabular@ResourceData["Sample Data: Guinea Pig Tooth Growth"], Lookup["Supplement"] -> KeyTake[{"Dose", "Length"}]]

Store the supplement types:

Wolfram Language code: supplements = Keys[growth]

Fit polynomial models up to a quadratic degree (the number of doses minus one):

Wolfram Language code: models = AssociationMap[ModelFit[growth[#1] -> {"Dose", "Length"}, PolynomialModel[UpTo[2], d]]&, supplements]

Compare the fits side by side. Orange juice shows a decrease in efficacy at higher doses, while vitamin C does not reach the predicted maximum within the tested range:

Wolfram Language code: Table[Show[ ListPlot[growth[s] -> {"Dose", "Length"}, ...], Plot[models[s][x], {x, Quantity[0, "Milligrams"], Quantity[2, "Milligrams"]}]], {s, supplements}]

Identify the dose that maximizes predicted tooth growth for each intervention:

Wolfram Language code: doses = First[Quantity[d, "Milligrams"] /. Solve[D[Information[#, "Expression"], d] == 0, d]]& /@ models

Retrieve the predicted tooth lengths at the projected maximum doses:

Wolfram Language code: length = MapThread[Construct, {models, doses}]

Car Fuel Economy  (1)

To determine the expected miles per gallon of a given car, first retrieve data on a variety of models:

Wolfram Language code: cars = ResourceData["Sample Tabular Data: Car Models"]

Both the weight and the horsepower might be expected to predict mpg, however, heavier cars will need higher horsepower motors. To establish if these are independent variables, use IndependenceTest :

Wolfram Language code: IndependenceTest[cars[[All, "horsepower"]], cars[[All, "weight"]]]

The extremely low p-value indicates that the two variables are highly dependent. Therefore, fit the mpg only according to the more easily verifiable car weight:

Wolfram Language code: model = ModelFit[cars -> {"weight", "mpg"}, PolynomialModel[]]

Confirm the fit by visualizing the fit:

Wolfram Language code: Show[ListPlot[cars -> {"weight", "mpg"}], Plot[model[x], {x, Splice@MinMax[cars[[All, "weight"]]]}, PlotStyle -> StandardOrange]]

Predict the mpg of a car, using automatic unit conversion:

Wolfram Language code: model[Quantity[1750, "Kilograms"]]

Interpolation and Extrapolation  (1)

Construct smooth surfaces between known data points for visualization:

Wolfram Language code: SeedRandom[1234]; data = GaussianFilter[RandomReal[1, {30, 30}], 3];
Wolfram Language code: ListPointPlot3D[data]

Add input values to the grid and flatten the data:

Wolfram Language code: input = Flatten[MapIndexed[Append[Reverse@#2, #1]&, data, {2}], 1];

Fit a polynomial model of high degree:

Wolfram Language code: poly = ModelFit[input, PolynomialModel[7]]

Plot the fitted surface with the points:

Wolfram Language code: ListPointPlot3D[data, PlotFit -> poly]

Possible Issues  (1)

When specifying the custom parameter symbols, there must be the same number of parameters as terms:

Wolfram Language code: PolynomialModel[2, {a, b}, 1]

Check the number of terms of a degree-two single-variable polynomial:

Wolfram Language code: Information[PolynomialModel[2, 1], "ParameterCount"]

Specify the third parameter using the standard notation:

Wolfram Language code: PolynomialModel[2, {a, b, C[3]}, 1]

Interactive Examples  (1)

Interactively adjust the polynomial degree of a fit:

Wolfram Language code: Manipulate[With[{data = {...}}, {fit = ModelFit[data, PolynomialModel[n]]}, Plot[fit[x], {x, -3, 5}, Prolog -> Point[data], PlotRange -> MinMax /@ Transpose[data]] ], {{n, 2}, 0, 5, 1, ControlType -> Setter}]
Wolfram Research (2026), PolynomialModel, Wolfram Language function, https://reference.wolfram.com/language/ref/PolynomialModel.html.

Text

Wolfram Research (2026), PolynomialModel, Wolfram Language function, https://reference.wolfram.com/language/ref/PolynomialModel.html.

CMS

Wolfram Language. 2026. "PolynomialModel." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/PolynomialModel.html.

APA

Wolfram Language. (2026). PolynomialModel. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/PolynomialModel.html

BibTeX

@misc{reference.wolfram_2026_polynomialmodel, author="Wolfram Research", title="{PolynomialModel}", year="2026", howpublished="\url{https://reference.wolfram.com/language/ref/PolynomialModel.html}", note=[Accessed: 15-August-2026]}

BibLaTeX

@online{reference.wolfram_2026_polynomialmodel, organization={Wolfram Research}, title={PolynomialModel}, year={2026}, url={https://reference.wolfram.com/language/ref/PolynomialModel.html}, note=[Accessed: 15-August-2026]}

Top [フレーム]

AltStyle によって変換されたページ (->オリジナル) /