Dividing two functions

Is there a way to divide 2 user defined functions ?

~Thanks.

Hi,

if you mean TF1s, yes:

root [0] TF1 f("f","x",0,10)
(TF1 &) Name: f Title: x
root [1] TF1 g("g","1/x",0,10)
(TF1 &) Name: g Title: 1/x
root [2] TF1 h("h","f/g",0,10)

Danilo

HI Danilo,
Thank you for your reply.
In fact I have to get this function from a root file and this method was not working (my function is a pointer type, I am not sure if this is the reason).
In mean between I tried the following & it worked.

h1->Add(f1);
h2->Add(f2);
h1->Divide(h2);
[h1 & h2 are blank histograms]

Any way, thank you for helping this. :slight_smile:

Hi,

from the first post it was not clear that you were dealing with histograms.
Indeed the snippet does the job: glad you found a solution.

Cheers,
Danilo

Actually, he wasn’t dealing with histograms. He just solved his dilemma with functions by converting them to histograms and dividing the histograms.