# TF1 with a function written by the user?

**URL:** <https://root-forum.cern.ch/t/tf1-with-a-function-written-by-the-user/36471>\
**Category:** Newbie\
**Created:** [October 23, 2019, 4:02pm UTC](https://root-forum.cern.ch/t/tf1-with-a-function-written-by-the-user/36471 "2019-10-23T16:02:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alberto96](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/278dde/32.png) [@alberto96](https://root-forum.cern.ch/u/alberto96)\
**Post date:** [October 23, 2019, 4:02pm UTC](https://root-forum.cern.ch/t/tf1-with-a-function-written-by-the-user/36471/1 "2019-10-23T16:02:43Z")

</div>

Hi, I want to create a macro that takes a function written by the user in cmd and draws it with TF1:

```auto
void DrawFunction(function)
{
     TF1* fa1 = new TF1("fa1", function, 0, 10);
     fa1->Draw(); 
}

```

but I have tried different options but I have always error.

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [October 23, 2019, 4:04pm UTC](https://root-forum.cern.ch/t/tf1-with-a-function-written-by-the-user/36471/2 "2019-10-23T16:04:39Z")

</div>

[TF1 Class Reference](https://root.cern.ch/doc/master/classTF1.html)
