{ "cells": [ { "cell_type": "markdown", "id": "b69528f3", "metadata": {}, "source": [ "# Legendre\n", "Example of first few Legendre Polynomials.\n", "\n", "Draws a graph.\n", "\n", "\n", "\n", "\n", "**Author:** Lorenzo Moneta \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:25 PM." ] }, { "cell_type": "code", "execution_count": 1, "id": "4fdcbc03", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:25:36.187623Z", "iopub.status.busy": "2026-05-19T20:25:36.187484Z", "iopub.status.idle": "2026-05-19T20:25:36.532442Z", "shell.execute_reply": "2026-05-19T20:25:36.531742Z" } }, "outputs": [], "source": [ "TCanvas *Canvas = new TCanvas(\"DistCanvas\", \"Legendre polynomials example\", 10, 10, 750, 600);\n", "Canvas->SetGrid();\n", "TLegend *leg = new TLegend(0.5, 0.7, 0.4, 0.89);" ] }, { "cell_type": "markdown", "id": "ae9ba8f6", "metadata": {}, "source": [ "drawing the set of Legendre functions" ] }, { "cell_type": "code", "execution_count": 2, "id": "d936f3dd", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:25:36.534678Z", "iopub.status.busy": "2026-05-19T20:25:36.534536Z", "iopub.status.idle": "2026-05-19T20:25:36.741436Z", "shell.execute_reply": "2026-05-19T20:25:36.740727Z" } }, "outputs": [], "source": [ "TF1* L[5];\n", "for(int nu = 0; nu <= 4; nu++)\n", "{\n", " L[nu]= new TF1(\"L_0\", \"ROOT::Math::legendre([0],x)\", -1, 1);\n", " L[nu]->SetParameters(nu, 0.0);\n", " L[nu]->SetLineStyle(kSolid);\n", " L[nu]->SetLineWidth(2);\n", " L[nu]->SetLineColor(nu+1);\n", "}\n", "L[0]->SetMaximum(1);\n", "L[0]->SetMinimum(-1);\n", "L[0]->SetTitle(\"Legendre polynomials\");\n", "leg->AddEntry(L[0]->DrawCopy(), \" L_{0}(x)\", \"l\");\n", "leg->AddEntry(L[1]->DrawCopy(\"same\"), \" L_{1}(x)\", \"l\");\n", "leg->AddEntry(L[2]->DrawCopy(\"same\"), \" L_{2}(x)\", \"l\");\n", "leg->AddEntry(L[3]->DrawCopy(\"same\"), \" L_{3}(x)\", \"l\");\n", "leg->AddEntry(L[4]->DrawCopy(\"same\"), \" L_{4}(x)\", \"l\");\n", "leg->Draw();\n", "\n", "Canvas->cd();" ] }, { "cell_type": "markdown", "id": "3ba51cc7", "metadata": {}, "source": [ "Draw all canvases " ] }, { "cell_type": "code", "execution_count": 3, "id": "adf159a0", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:25:36.743697Z", "iopub.status.busy": "2026-05-19T20:25:36.743561Z", "iopub.status.idle": "2026-05-19T20:25:37.054234Z", "shell.execute_reply": "2026-05-19T20:25:37.052907Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", "
\n", "\n", "\n", "\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "gROOT->GetListOfCanvases()->Draw()" ] } ], "metadata": { "kernelspec": { "display_name": "ROOT C++", "language": "c++", "name": "root" }, "language_info": { "codemirror_mode": "text/x-c++src", "file_extension": ".C", "mimetype": " text/x-c++src", "name": "c++" } }, "nbformat": 4, "nbformat_minor": 5 }