Problem with MathMore

ROOT Version: 6.24/02
Platform: Ubuntu preview on Windows
Compiler: gcc


Good evening, this is my first question in the forum so I will try my best to be clear enough. I am trying to perform a fit of some experimental data with the function sigma_swave implemented below

double const kb=1.3806*pow(10,-23);
double const pi=3.14159;
double fit(double *x, double *par)
{
	double fit;
	fit=par[0]*(1-pow(x[0]/par[1],4));
	return fit;
}
double Delta_s(double *x, double *par)
{
	double Delta_s=par[0]*TMath::ATan(1.82*pow(1.082*(par[1]/x[0]-1),0.51));
	return Delta_s;
}
double f(double *x, double *par)
{
	TF1 *Delta=new TF1("Delta",Delta_s,0,5,2);
	Delta->SetParameters(par[0],par[1]);
	double FermiDirac=pow(1+TMath::Exp(sqrt(x[0]*x[0]+Delta->Eval(par[2])*Delta->Eval(par[2]))/(kb*par[2])),-1);
	double f=FermiDirac*(1-FermiDirac);
	return f;
}

double sigma_swave(double *x,double *par)
{
	TF1 *fu=new TF1("fu",f,0,99999,3);
	fu->SetParameters(par[0],par[1],x[0]);
	auto integral=fu->Integral(0,99999);
	double sigma=par[2]*(2/(kb*x[0]))*integral;
	return sigma;
}

which involves an integral of a 2d function over just one variable from 0 to infinity. The first question is related to the calculation of the integral: is there an alternative method that doesn’t require a finite interval? The second question is related to the error I have after the calculation of the fit:

cling::DynamicLibraryManager::loadLibrary(): libgsl.so.23: cannot open shared object file: No such file or directory
Error in TInterpreter::TCling::AutoLoad: failure loading library libMathMore.so for ROOT::Math::GSLIntegrator
cling::DynamicLibraryManager::loadLibrary(): libgsl.so.23: cannot open shared object file: No such file or directory
Warning in ROOT::Math::IntegratorOneDim::CreateIntegrator: Error loading one dimensional GSL integrator - use Gauss integrator.

I already tried to solve the problem by using sudo apt-get install libgsl-dev, but then the following appears:

The following packages have unmet dependencies: apt-file : Depends: libregexp-assemble-perl but it is not going to be installed
 liblist-moreutils-perl : Depends: liblist-moreutils-xs-perl but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution). 

May I ask if the problem is related to that and how to fix it?

Hello @gzotti,
thank you for reaching out!
Your code looks somehow incomplete to me, in sense that I see some function definitions but I don’t see any function call. Can you provide a full code snippet please?
For what concerns the error you reported, have you tried to run the suggested command apt --fix-broken install to solve your issue? You can also try to fix your system dependencies by running

sudo apt-get install -f
sudo dpkg-configure -a
sudo apt-get install -f

before trying the installation again.

Let me know if any of the above suggestions work.

Cheers,
Monica

Thank you very much, the complete macro is the following one

double const kb=1.3806*pow(10,-23);
double const pi=3.14159;
double fit(double *x, double *par)
{
	double fit;
	fit=par[0]*(1-pow(x[0]/par[1],4));
	return fit;
}
double Delta_s(double *x, double *par)
{
	double Delta_s=par[0]*TMath::ATan(1.82*pow(1.082*(par[1]/x[0]-1),0.51));
	return Delta_s;
}
double f(double *x, double *par)
{
	TF1 *Delta=new TF1("Delta",Delta_s,0,5,2);
	Delta->SetParameters(par[0],par[1]);
	double FermiDirac=pow(1+TMath::Exp(sqrt(x[0]*x[0]+Delta->Eval(par[2])*Delta->Eval(par[2]))/(kb*par[2])),-1);
	double f=FermiDirac*(1-FermiDirac);
	return f;
}

double sigma_swave(double *x,double *par)
{
	TF1 *fu=new TF1("fu",f,0,99999,3);
	fu->SetParameters(par[0],par[1],x[0]);
	auto integral=fu->Integral(0,99999);
	double sigma=par[2]*(2/(kb*x[0]))*integral;
	return sigma;
}
void plots(std::string title)
{
	TGraphErrors *Sigma=new TGraphErrors();
	TGraphErrors *Bsc=new TGraphErrors();
	Sigma->SetTitle("SC sigma");
	Bsc->SetTitle("SC field");
	ifstream in;
	in.open(title);
	Float_t t,sigma,err_sigma,Bscc,err_Bsc;
	int i=1;
	while(1)
	{
		in>>t>>sigma>>err_sigma>>Bscc>>err_Bsc;
		if(!in.good()) break;
		Sigma->SetPoint(i,t,sigma);
		Sigma->SetPointError(i,0,err_sigma);
		Bsc->SetPoint(i,t,Bscc);
		Bsc->SetPointError(i,0,err_Bsc);
		++i;
	}
        TF1 *f=new TF1("f",sigma_swave,0,5,3);
	f->SetParameters(0.1,2,0.22);
	Sigma->Fit("f","R");
	TCanvas *c=new TCanvas();
	Sigma->SetMarkerStyle(3);
	Sigma->SetMarkerColor(kRed);
	Sigma->GetYaxis()->SetRangeUser(0,0.35);
	Bsc->SetMarkerColor(kRed);
	Sigma->GetXaxis()->SetTitle("Temperature (K)");
	Sigma->GetYaxis()->SetTitle("SC Sigma (us^(-1))");
	Sigma->Draw("APE");
	f->Draw("SAME");
	Bsc->SetMarkerStyle(3);
	Bsc->GetXaxis()->SetTitle("Temperature (K)");
	Bsc->GetYaxis()->SetTitle("SC field (gauss)");
	TCanvas *c1=new TCanvas();
	Bsc->GetYaxis()->SetRangeUser(148,152);
	Bsc->Draw("APE");
	std::cout<<"Chi square = "<<f->GetChisquare()/f->GetNDF()<<'\n';
}

I will try as soon as possible the suggested commands and let you know

I saved your code in a file test.C and in order to be able to run it, I included the following function call (tell me if there’s something I am missing)

void test(){

plots("test");
}

I receive the following warning: Warning in <Fit>: Fit data is empty. Is it the case for you too?

Good evening,
actually after adding the function test() to the code I have no warnings from the compiler and the usual:
cling::DynamicLibraryManager::loadLibrary(): libgsl.so.23: cannot open shared object file: No such file or directory
Error in TInterpreter::TCling::AutoLoad: failure loading library libMathMore.so for ROOT::Math::GSLIntegrator
cling::DynamicLibraryManager::loadLibrary(): libgsl.so.23: cannot open shared object file: No such file or directory
Warning in ROOT::Math::IntegratorOneDim::CreateIntegrator: Error loading one dimensional GSL integrator - use Gauss integrator
cling::DynamicLibraryManager::loadLibrary(): libgsl.so.23: cannot open shared object file: No such file or directory
Error in TInterpreter::TCling::AutoLoad: failure loading library libMathMore.so for ROOT::Math::GSLIntegrator.
The commands you suggested seem not to be working, I will try to reinstall root

Hello @gzotti, the warning that I pointed is appearing at execution time by running your code through the command line interpreter as follows

$ root test.C

I believe that your code may have some problems since the fit data is empty as indicated.
On the other hand, I don’t believe that your problem is related to your ROOT installation but rather to your gsl installation. Did you try to fix your unmet dependencies by running sudo apt --fix-broken install before retrying the installation?

Sorry, probably I was not clear. After the execution of the code I have the following

root@PC-Gio:~# root test.c
root [0]
Processing test.c…
Chi square = -nan
cling::DynamicLibraryManager::loadLibrary(): libgsl.so.23: cannot open shared object file: No such file or directory
Error in TInterpreter::TCling::AutoLoad: failure loading library libMathMore.so for ROOT::Math::GSLIntegrator
cling::DynamicLibraryManager::loadLibrary(): libgsl.so.23: cannot open shared object file: No such file or directory
Warning in ROOT::Math::IntegratorOneDim::CreateIntegrator: Error loading one dimensional GSL integrator - use Gauss integrator

so strangely not the warning you have. I have already tried the command sudo apt–fix-broken install but it gave the following error:

Err:1 main amd64 liblist-moreutils-xs-perl amd64 0.430-3
404 Not Found [IP: 91.189.91.83 80]
Err:2 universe amd64 libregexp-assemble-perl all 0.38-1
404 Not Found [IP: 91.189.91.83 80]
E: Failed to fetch liblist-moreutils-xs-perl_0.430-3_amd64.deb 404 Not Found [IP: 91.189.91.83 80]
E: Failed to fetch libregexp-assemble-perl/libregexp-assemble-perl_0.38-1_all.deb 404 Not Found [IP: 91.189.91.83 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

and even --fix-missing seems not to be working

In that case you should try to look online for solutions to this problem, as it is clearly not related to ROOT. Googling your error, I see that you can try to upgrade the Ubuntu release by running

sudo apt-get dist-upgrade  

An alternative just for the purpose of making your code work could be building GSL from source, but at some point you should definitely fix your system dependencies in order to be able to run apt-get…

Thank you very much, I will try and let you know

Ok, it seems I solved the problem with GSL, now I have the same warning you highlighted after coding the void function test. So probably there are still some problems in the code, even if I don’t know why because the function seems well defined to me, at least at first sight