# TF1 with "sqrt" and "erf" will not draw (Python)

**URL:** <https://root-forum.cern.ch/t/tf1-with-sqrt-and-erf-will-not-draw-python/53561>\
**Category:** Newbie\
**Tags:** python\
**Created:** [February 9, 2023, 9:47pm UTC](https://root-forum.cern.ch/t/tf1-with-sqrt-and-erf-will-not-draw-python/53561 "2023-02-09T21:47:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![RNugent](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/53a042/32.png) [@RNugent](https://root-forum.cern.ch/u/RNugent)\
**Post date:** [February 9, 2023, 9:47pm UTC](https://root-forum.cern.ch/t/tf1-with-sqrt-and-erf-will-not-draw-python/53561/1 "2023-02-09T21:47:55Z")

</div>

Hello all,

I’ve been familiarizing myself with the TF1 class and have been trying to create a function with a “sqrt” and “erf” that both have a set parameter. My problem is when I go to draw the function with TCanvas() nothing appears. This only occurs with “sqrt” and “erf” as I successfully drew a function with “exp” but had to denote the “sqrt” as “x\*\*0.5”. I don’t know if this is a Python thing but any help would be appreciated.

 ![image](https://root-forum.cern.ch/uploads/default/original/3X/f/4/f499cae94b7cfc0a928348b1a570a0a6db6e3fc6.png)

_ROOT Version:_ 6.24.06  
_Platform:_ Windows 11  
_Compiler:_ JupyterHub

* * *

---

<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:** [February 10, 2023, 7:59am UTC](https://root-forum.cern.ch/t/tf1-with-sqrt-and-erf-will-not-draw-python/53561/2 "2023-02-10T07:59:53Z")

</div>

Can you copy/paste your script or attach the file instead of giving a screen dump?

---

<div class="post-metadata">

**Author:** ![RNugent](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/53a042/32.png) [@RNugent](https://root-forum.cern.ch/u/RNugent)\
**Post date:** [February 10, 2023, 1:15pm UTC](https://root-forum.cern.ch/t/tf1-with-sqrt-and-erf-will-not-draw-python/53561/3 "2023-02-10T13:15:51Z")

</div>

For sure. Sorry about that still a little green to this all.

[TF1 Familiarization.ipynb](https://root-forum.cern.ch/uploads/short-url/xWMUI554qHyrwl5YRABnxa5gfP1.ipynb) (35.9 KB)

---

<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:** [February 10, 2023, 1:18pm UTC](https://root-forum.cern.ch/t/tf1-with-sqrt-and-erf-will-not-draw-python/53561/4 "2023-02-10T13:18:52Z")

</div>

That’s a binary file … can you post your code as a script ? simple ascci file we can run ?

---

<div class="post-metadata">

**Author:** ![RNugent](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/53a042/32.png) [@RNugent](https://root-forum.cern.ch/u/RNugent)\
**Post date:** [February 10, 2023, 3:19pm UTC](https://root-forum.cern.ch/t/tf1-with-sqrt-and-erf-will-not-draw-python/53561/5 "2023-02-10T15:19:44Z")

</div>

[TF1 Familiarization.txt](https://root-forum.cern.ch/uploads/short-url/m1UxidKBTxIlAMNiQPz94zHANGg.txt) (1.2 KB)

---

<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:** [February 10, 2023, 4:10pm UTC](https://root-forum.cern.ch/t/tf1-with-sqrt-and-erf-will-not-draw-python/53561/6 "2023-02-10T16:10:13Z")

</div>

```auto
void RNugent() {
   auto C = new TCanvas();
   C->Divide(2,2);

   C->cd(1);
   auto testFunction = new TF1("tf","[0]*x*exp([1]*x)",-10,10);
   testFunction->SetParameter(0,0.1);
   testFunction->SetParameter(1,0.7);
   testFunction->SetLineColor(4);
   testFunction->Draw();

   C->cd(2);
   auto smallPhi = new TF1("phi","(1/(2)**0.5)*exp(-([0]*x)**2/2)",-10,10);
   smallPhi->SetParameter(0,2);
   smallPhi->SetParameter(1,0.7);
   smallPhi->SetLineColor(4);
   smallPhi->Draw();

   C->cd(3);
   auto errorFunction = new TF1("errF", "(1/sqrt([0]))*x*erf([0])", -10,10);
   errorFunction->SetParameter(0,3);
   errorFunction->SetLineColor(4);
   errorFunction->Draw();
}

```

 ![Screenshot 2023-02-10 at 17.09.29](https://root-forum.cern.ch/uploads/default/original/3X/1/e/1e3f1896aa62aeaeca3b37585a91811c503be13e.jpeg)
