{ "cells": [ { "cell_type": "markdown", "id": "865aa3ba", "metadata": {}, "source": [ "# rf710_roopoly\n", "Taylor expansion of RooFit functions using the taylorExpand function with RooPolyFunc\n", "\n", "\n", "\n", "\n", "**Author:** Rahul Balasubramanian \n", "This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Tuesday, May 19, 2026 at 08:34 PM." ] }, { "cell_type": "code", "execution_count": 1, "id": "9e6a5e07", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:35:02.144839Z", "iopub.status.busy": "2026-05-19T20:35:02.144733Z", "iopub.status.idle": "2026-05-19T20:35:02.160446Z", "shell.execute_reply": "2026-05-19T20:35:02.159870Z" } }, "outputs": [], "source": [ "%%cpp -d\n", "#include \"RooRealVar.h\"\n", "#include \"RooPolyFunc.h\"\n", "#include \"RooAbsCollection.h\"\n", "#include \"RooPlot.h\"\n", "#include \"TCanvas.h\"\n", "\n", "using namespace RooFit;" ] }, { "cell_type": "markdown", "id": "29b5bfc5", "metadata": {}, "source": [ "Create polynomial\n", "function of fourth order\n", "---------------------------------------------\n", "x^4 - 5x^3 + 5x^2 + 5x -6\n", "---------------------------------------------" ] }, { "cell_type": "code", "execution_count": 2, "id": "eea14192", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:35:02.162129Z", "iopub.status.busy": "2026-05-19T20:35:02.162004Z", "iopub.status.idle": "2026-05-19T20:35:02.560559Z", "shell.execute_reply": "2026-05-19T20:35:02.559643Z" } }, "outputs": [], "source": [ "RooRealVar x(\"x\", \"x\", 0, -3, 10);\n", "RooPolyFunc f(\"f\", \"f\", RooArgSet(x));\n", "f.addTerm(+1, x, 4);\n", "f.addTerm(-5, x, 3);\n", "f.addTerm(+5, x, 2);\n", "f.addTerm(+5, x, 1);\n", "f.addTerm(-6, x, 0);" ] }, { "cell_type": "markdown", "id": "bff1788c", "metadata": {}, "source": [ "Create taylor expansion\n", "---------------------------------------------" ] }, { "cell_type": "code", "execution_count": 3, "id": "2940a513", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:35:02.562264Z", "iopub.status.busy": "2026-05-19T20:35:02.562142Z", "iopub.status.idle": "2026-05-19T20:35:02.772584Z", "shell.execute_reply": "2026-05-19T20:35:02.771792Z" } }, "outputs": [], "source": [ "double x0 = 2.0;\n", "auto taylor_o1 = RooPolyFunc::taylorExpand(\"taylor_o1\", \"taylor expansion order 1\", f, {x}, 1, {x0});\n", "auto taylor_o2 = RooPolyFunc::taylorExpand(\"taylor_o2\", \"taylor expansion order 2\", f, {x}, 2, {x0});" ] }, { "cell_type": "markdown", "id": "6ad8e2c4", "metadata": {}, "source": [ "Plot polynomial with first and second order taylor expansion overlaid" ] }, { "cell_type": "code", "execution_count": 4, "id": "e32301bc", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:35:02.774217Z", "iopub.status.busy": "2026-05-19T20:35:02.774097Z", "iopub.status.idle": "2026-05-19T20:35:02.980327Z", "shell.execute_reply": "2026-05-19T20:35:02.979627Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "