User-defined function with numbering of parameters

Good afternoon!

I would like to define a composite function similar to

TF1 *f = new TF1("f", "gausn(0) + gausn(3)");

but with own functions instead of gausn-s.

I have defined a custom function,

double test_fun(double *x, double *p){
    return p[0] * log(*x + p[1]) * exp(p[2] * (*x));
}

and I want to define a new function as

TF1 *f1 = new TF1("f1", "test_fun(0) + test_fun(3)", 0.2, 5.2, 6);

Is it possible to do so?
And if so, how?

Best regards,
Natalia

I guess @moneta can help you

Does @moneta know about this, or I have somehow connect him?

No, you do not need to connect to him. just mentioning @moneta in a post is enough

1 Like

Hi @Natalia_D,

your question seems similar to this exercise: student-course/course/exercises/core/fitting-exercise.ipynb at main · root-project/student-course · GitHub

If you’re new to ROOT in general, I recommend that you go through the whole course: GitHub - root-project/student-course: ROOT course for students - there is a section dedicated to functions and fitting as well, you can also watch the recording of the course and follow the material along with it: ROOT Summer Student Course 2024 · CDS Videos · CERN

Cheers,
Marta