# Covariance matrix calculation after multiplication of two fitting function

I have two TF1 functions f1 and f2. f1 is used to fit some data set and f2 is used to fit some other data set. Now I have a 3rd function f3 which is the multiplication of f1 and f2. The parameters and errors in parameter of f3 are those obtained from fitting of two data sets by f1 and f2. Now I am trying to calculate IntegralError in the function f3 for which I have to supply the covariance matrix. Since f1 and f2 are used in fitting I can calculate their covariance matrix but how to find covariance matrix of the third function f3 which is just the multiplication of two functions f1 and f2 ?

ROOT Version: 6.16
Platform: Mac OS
Compiler: Not Provided

Hi,

Is `f3(x,p) = f1(x,p1)*f2(x,p2)` with parameters p1 and p2 all different ant not in common ?

If this is the case you need just to make a big covariance matrix for the parameters p of f3 by concatenating the two covariance matrices for p1 and p2.
For example from the TFitResut result1 and result2 from the to fits you can do:

``````cov1 = result1->GetCovarianceMatrix();  // cov matrix of first fit
cov2 = result2->GetCovarianceMatrix();  // cov matrix of second fit
TMatrixDSym cov = cov1;
int n1 = cov1.GetNrows();
int n2 = cov2.GetNrows();
cov.ResizeTo(n1+n2,n1+n2);
cov.SetSub(n1,n1,cov2);     // cov is now the concataneted cov matrix
``````

Lorenzo

Hi moneta,
Thank you. I works great.