Formula 1

TF1 example.

Author: Wim Lavrijsen
This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Thursday, June 04, 2020 at 02:44 AM.

In [1]:
from ROOT import TCanvas, TFormula, TF1
from ROOT import gROOT, gObjectTable

c1 = TCanvas( 'c1', 'Example with Formula', 200, 10, 700, 500 )
Welcome to JupyROOT 6.23/01

We create a formula object and compute the value of this formula for two different values of the x variable.

In [2]:
form1 = TFormula( 'form1', 'sqrt(abs(x))' )
form1.Eval( 2 )
form1.Eval( -45 )
Out[2]:
6.708203932499369

Create a one dimensional function and draw it

In [3]:
fun1 = TF1( 'fun1', 'abs(sin(x)/x)', 0, 10 )
c1.SetGridx()
c1.SetGridy()
fun1.Draw()
c1.Update()

Before leaving this demo, we print the list of objects known to ROOT

In [4]:
if ( gObjectTable ):
    gObjectTable.Print()
Object statistics
class                         cnt    on heap     size    total size    heap size
================================================================================
TList                         136        136      104         14144        14144
TObjectTable                    1          1       32            32           32
TROOT                           1          0      704           704            0
TPluginManager                  1          1       40            40           40
THashTable                      1          1       72            72           72
THashList                       1          1      112           112          112
TEnv                            1          1       56            56           56
TEnvRec                       153        153       96         14688        14688
TUnixSystem                     1          1      672           672          672
TOrdCollection                  5          5       72           360          360
--------------------------------------------------------------------------------
Total:                        301        300     1960         30880        30176
================================================================================

Draw all canvases

In [5]:
%jsroot on
from ROOT import gROOT 
gROOT.GetListOfCanvases().Draw()