18x = ROOT.RooRealVar(
"x",
"x", 0.0, -3, 10)
24f = ROOT.RooPolyFunc(
"f",
"f", ROOT.RooArgList(x))
31f = ROOT.RooFormulaVar(
"f",
"f",
"pow(@0,4) -5 * pow(@0,3) +5 * pow(@0,2) + 5 * pow(@0,1) - 6", [x])
35taylor_o1 = ROOT.RooPolyFunc.taylorExpand(
"taylorfunc_o1",
"taylor expansion order 1", f, [x], 1, [x0])
36taylor_o2 = ROOT.RooPolyFunc.taylorExpand(
"taylorfunc_o2",
"taylor expansion order 2", f, [x], 2, [x0])
37frame = x.frame(Title=
"x^{4} - 5x^{3} + 5x^{2} + 5x - 6")
38c = ROOT.TCanvas(
"c",
"c", 400, 400)
40f.plotOn(frame, Name=
"f")
41taylor_o1.plotOn(frame, Name=
"taylor_o1", LineColor=
"kRed", LineStyle=
"kDashed")
42taylor_o2.plotOn(frame, Name=
"taylor_o2", LineColor=
"kRed - 9", LineStyle=
"kDotted")
47frame.SetYTitle(
"function value")
50legend = ROOT.TLegend(0.53, 0.73, 0.86, 0.87)
51legend.SetFillColor(ROOT.kWhite)
52legend.SetLineColor(ROOT.kWhite)
53legend.SetTextSize(0.02)
54legend.AddEntry(
"taylor_o1",
"Taylor expansion upto first order",
"L")
55legend.AddEntry(
"taylor_o2",
"Taylor expansion upto second order",
"L")
56legend.AddEntry(
"f",
"Polynomial of fourth order",
"L")
60c.SaveAs(
"rf710_roopoly.png")