# Problem with fitting ATan function

**URL:** <https://root-forum.cern.ch/t/problem-with-fitting-atan-function/44941>\
**Category:** Newbie\
**Created:** [May 18, 2021, 7:23am UTC](https://root-forum.cern.ch/t/problem-with-fitting-atan-function/44941 "2021-05-18T07:23:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gorsedh](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/gorsedh/32/25831_2.png) [@gorsedh](https://root-forum.cern.ch/u/gorsedh)\
**Post date:** [May 18, 2021, 7:23am UTC](https://root-forum.cern.ch/t/problem-with-fitting-atan-function/44941/1 "2021-05-18T07:23:10Z")

</div>

[fasi.txt](https://root-forum.cern.ch/uploads/short-url/bYNZf5x4ZiLDoabLbtnx7Af4eRU.txt) (1.8 KB)  
[main.cpp](https://root-forum.cern.ch/uploads/short-url/5IxISPDQSrVxVuCcQrcGTgEc8XE.cpp) (663 Bytes)  
[macro.cpp](https://root-forum.cern.ch/uploads/short-url/xvkbd6KtgOWdvSzpJPQ1HJtNUpj.cpp) (534 Bytes)

Hello,  
I’m trying to fit a set of data but (even after initialising the parameters) i’m getting this error several times:

Error in TFormula::Eval: Formula is invalid and not ready to execute  
TMath::Pi is unknown.  
Tmath::Pi is unknown.  
TMath::ATan is unknown.

I don’t understand why it shouldn’t work since i’ve always fitted my data like this. I’ve tried both running the code on root for windows (interpreted macro.cpp) and linux (compiled main.cpp) but i’m always getting the same error.

Sometimes i get some fit results but they are clearly wrong (i’m expecting p0 to be approximately 1 and p1 to be around 10^-5 or 10^-6, and i get results of 10^3 with an uncertainty of around 10^4. Sometimes it plots a straight line on the zero (the picture shows the straight line on the zero, it comes from the same dataset with the same code for the fit)

 ![photo_2021-05-17_22-24-48](https://root-forum.cern.ch/uploads/default/original/3X/b/4/b43fa8942e82f556d2f50d4ccc3d57b4d16b5d00.jpeg)

Does anyone have an idea of why it behaves like this?

Thank you very much for your help

ROOT Version: 8.18/04 for win32, 6.22/02 for linuxx8664gcc

Edit: “Attesa” is the function generated with the data i’ve collected in the laboratory, and it reminds of the shape of the experimental data so i don’t understand why it can’t fit

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [May 18, 2021, 7:54am UTC](https://root-forum.cern.ch/t/problem-with-fitting-atan-function/44941/2 "2021-05-18T07:54:36Z")

</div>

`Tmath` should be `TMath`
