How to write "[0] * x" using linear function?

I want to fit a TGraph with a linear function. I want to specify it is linear with the ++ sign, as in " x ++ 1". The point is that I don’t want the offset. If I use just “x” ROOT says: “Error in : function fit_function has illegal number of parameters = 0”

Hi,

You can use “pol1” or “x++1”, and fix the offset parameter to the zero value. Otherwise you might try to make a TF1 using “[0]*x”, but in this case you must set the linear bit by hand, by doing:
TFormula.SetBit(TFormula::kLinear);

Best Regards

Lorenzo