Documentation › Fit functions
Fit functions
A fit function is ultimately a ROOT TFormula expression. You can write one directly, or use the equation editor, which translates ordinary mathematical notation into that expression and shows you the result.
ROOT expressions
Write x for the independent variable and [0], [1], … for the parameters. Parameters are identified by their index, not by name: in [0]*x+[1], [0] is the slope and [1] the intercept, and the report names, starting values and Analyze Data symbols all follow that order. Arithmetic is + - * /, powers are pow(x,2) or x^2, and the usual functions are available: exp, log (natural), log10, sqrt, abs, sin, cos, tan, their inverses and hyperbolic forms, and the TMath:: library (TMath::Pi(), TMath::Erf(x), …). A conditional a==0?1:b avoids a 0/0, as in a sinc function.
ROOT also defines named functions: gaus (amplitude, mean, sigma), gausn (the same, normalised to unit area), expo (exp(a + b x)), landau, and the polynomials pol0 … pol9. They can be combined with a parameter offset in parentheses: gaus(0)+pol1(3) uses [0]–[2] for the peak and [3], [4] for the line. For a plain polynomial or a single named function ROOT can estimate starting values itself; for a sum it cannot, and the starting values matter.
Expressions are checked on the server before fitting; a function ROOT does not know, or unbalanced brackets, come back as an error naming the problem.
The equation editor
The Equation editor mode accepts a formula typed the way it would be written by hand, rendered as mathematics as you type: A exp(-x/tau) + B, a x^2 + b x + c, I_0 cos(k x)^2. Every letter or symbol other than x becomes a fit parameter, in order of first appearance, and the generated ROOT expression is shown under the editor. The translation is deliberately limited to what ROOT can express, so it is exact: adjacent symbols multiply, / makes a fraction, ^ a power and _ a subscript, \sqrt a root, and Greek letters are typed as \tau, \lambda and so on followed by Space. Functions take parentheses. e and pi are constants, not parameters. Anything outside this grammar is refused with a message rather than guessed at; switch to the ROOT expression mode for it.
Parameter symbols from the editor carry through the whole analysis: the report, the AI prompt and the Analyze Data chips use τ rather than [1]. The Report name column of the parameter table lets you give a parameter a longer name for the report without changing its symbol.
The model library
Choose a model… opens a searchable library grouped by topic: mechanics and motion, waves and optics, thermal and statistical, electricity and magnetism, modern physics, and general shapes. Each entry gives the model as an equation, the experiment it describes, the variables it expects on each axis, and short guidance on reading each starting value from the data. Use fills the equation, the parameter names and generic starting values. Those values are placeholders for a typical scale, not estimates from your data; the preview on the Fit model step will usually show the curve nowhere near the points until you set them (see Starting values).
The library is not a constraint. Any model can be edited after loading, and a model written from scratch is fitted exactly the same way.
Fit range
Under the parameter table, a fit range restricts the fit to points with x inside [min, max] (ROOT option R). Points outside stay on the plot but do not enter χ². Use it when the model describes only part of the data, for example the linear region of a saturating curve. To leave out particular points rather than a range, use point exclusions.