Question: The Legendre polynomials, P n ( x ) , are a system of orthogonal polynomials discovered in 1 7 8 2 by French mathematician Adrien

The Legendre polynomials, Pn(x), are a system of orthogonal polynomials discovered in 1782 by French mathematician Adrien-Marie Legendre. Pn(x) is given by Bonnet's recurrence relation
Pn(x)=2n-1nxPn-1(x)-n-1nPn-2(x)
for real x in the interval -1,1 and integer n>1 with Pn(x)=1 for n=0 and Pn(x)=x for n=1. A plot of Legendre polynomials for n=0 to 5 is shown in the figure below.
Develop a code that computes Pn(x) for values of n from 0 to 5 in an iterative structure that implements the recurrence relation using a recursive function for Pn(x). Observe Pn(x) is a function of Pn-1(x) and Pn-2(x). Thus, define a recursive function
that invokes a call to itself via Pn(n-1,x) and Pn(n-2,x). Print values of Pn(x) in intervals of x=0.5. Example output:
x:,-1.000,-0.500,0.000,0.500,1.000
n=0:,1.000,1.000,1.000,1.000,1.000
n=1:,-1.000,-0.500,0.000,0.500,1.000
n=2:,1.000,-0.125,-0.500,-0.125,1.000
n=3:,-1.000,0.438,-0.000,-0.438,1.000
n=4:,1.000,-0.289,0.375,-0.289,1.000
n=5:,-1.000,-0.090,0.000,0.090,1.000
Use the Matplotlib library to generate the figure above and render your plot within your Jupyter Notebook. Once you have your algorithm working, increase the resolution of your plot by using 100(or more) linearly spaced values for x on the interval -1,1.
"code with python"
 The Legendre polynomials, Pn(x), are a system of orthogonal polynomials discovered

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!