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 Tuesday, June 22, 2021 at 08:30 AM.

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

c1 = TCanvas( 'c1', 'Example with Formula', 200, 10, 700, 500 )

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

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

Create a one dimensional function and draw it

In [ ]:
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 [ ]:
if ( gObjectTable ):
    gObjectTable.Print()

Draw all canvases

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