I have an equation that depends on more than one variable. I know that if the dependence is y=f(x) then I can use the TF1 function, e.g.,

TF1 *fit = new TF1("fit", "[0] + [1]* x + [2]* x* x");

However, in my case, I want to fit something like Z = p + q A + r B, where A and B are independent variables. As a temporary solution, I am using desmos.com. It fits parameters p, q, and r. Please let me know how I can do this with ROOT.

I mean what to do if there are three or more independent variables? That is Z = p + q A + r B + s C, where A, B, and C are the independent variables and p, q, r, and s are the fitting parameters.

Hi Divyang, good to see that you problem is solved â€¦ for the moment. So what are going to do when you encounter a problem with 10 independent variables, use a TF10 or TH10 ?

What you are looking for is the solution to a linear regression problem. Implementations in ROOT vary from applying the linear algebra package to using roofit .