Brad Roundy

5 Reputation

2 Badges

13 years, 298 days

MaplePrimes Activity


These are replies submitted by Brad Roundy

I appreciate it, but my teacher already helped me to write the code. Thanks anyway!!!

I appreciate it, but my teacher already helped me to write the code. Thanks anyway!!!

Thankyou for your reply, I tried to modify your code to do the process that I am looking for, but couldn't figure out how to get it to work. Here is what I tried:

This is what I am looking for the code to do:

.

.

.

 

It will generate the Legendre Polynomials.

Thanks,

 

Thankyou for your reply, I tried to modify your code to do the process that I am looking for, but couldn't figure out how to get it to work. Here is what I tried:

This is what I am looking for the code to do:

.

.

.

 

It will generate the Legendre Polynomials.

Thanks,

 

Thanks for your reply! I should of mentioned that I am doing this to learn about programing in maple and for my class. My teacher wants us to learn how to program our own code and not use maple's quick commands. My assignement is to program a code for Gaussian Quadrature Integration Approximations. Now, writing a code for the Legendre polynomials is related to this assignment and I was hoping that I could get some examples of code so that I can ultimately be able to write my own for Gaussian Quadrature.

Can anyone help me write a code to generate the Legendre polynomials of degree n using this process?

 

I noticed that on my original post, most of what I typed had been deleted. Not sure what happened, or if anyone else is wondering what I typed. I am reposting the process I wrote previously and this time it better not erase. I also thought that maybe it was my notation that caused the problem, so I altered my notation from <p,q> to (p,q) for the inner product.

 

Given "(f) = {f[0]=1, f[1]=x , f[2]=x^(2) , f[3]=x^(3) , ... , f[n]=x^(n)} "
       
Find the Legendre Polynomials: "{P[0] , P[1] , P[2] , P[3] , ... , P[n]}"

First,  P[0]=f[0]=1

then, the rest are defined recursively by

P[1]=f[1]-(f[1],P[0])/(P[0],P[0])*P[0] = x

P[2]=f[2]-(f[2],P[0])/(P[0],P[0])*P[0]-(f[2],P[1])/(P[1],P[1])*P[1] = x^2-1/3

P[3]=f[3]-(f[3],P[0])/(P[0],P[0])*P[0]-(f[3],P[1])/(P[1],P[1])*P[1]-(f[3],P[2])/(P[2],P[2])*P[2] = x^3-(3/5)x

P[4]=f[4]-(f[4],P[0])/(P[0],P[0])*P[0]-(f[4],P[1])/(P[1],P[1])*P[1]-(f[4],P[2])/(P[2],P[2])*P[2]-(f[4],P[3])/(P[3],P[3])*P[3] = x^4-(6/7)x^2+3/35

.

.

.

P[n]=f[n]-(f[n],P[0])/(P[0],P[0])*P[0]-(f[n],P[1])/(P[1],P[1])*P[1]-...-(f[n],P[i])/(P[i],P[i])*P[i]-...-(f[n],P[n-1])/(P[n-1],P[n-1])*P[n-1]

 

where in general, (f[k],P[i])/(P[i],P[i])*P[i] = (int(f[k]*P[i], x = -1 .. 1))/(int(P[i]*P[i], x = -1 .. 1))*P[i], for all i=0,1,2,...,k-1 and some k among 1, 2, ... , n.


ie. the inner product  (p,q)= int(p(x)*q(x), x = -1 .. 1).

 

Thanks,

Brad

Thanks for your reply! I should of mentioned that I am doing this to learn about programing in maple and for my class. My teacher wants us to learn how to program our own code and not use maple's quick commands. My assignement is to program a code for Gaussian Quadrature Integration Approximations. Now, writing a code for the Legendre polynomials is related to this assignment and I was hoping that I could get some examples of code so that I can ultimately be able to write my own for Gaussian Quadrature.

Can anyone help me write a code to generate the Legendre polynomials of degree n using this process?

 

I noticed that on my original post, most of what I typed had been deleted. Not sure what happened, or if anyone else is wondering what I typed. I am reposting the process I wrote previously and this time it better not erase. I also thought that maybe it was my notation that caused the problem, so I altered my notation from <p,q> to (p,q) for the inner product.

 

Given "(f) = {f[0]=1, f[1]=x , f[2]=x^(2) , f[3]=x^(3) , ... , f[n]=x^(n)} "
       
Find the Legendre Polynomials: "{P[0] , P[1] , P[2] , P[3] , ... , P[n]}"

First,  P[0]=f[0]=1

then, the rest are defined recursively by

P[1]=f[1]-(f[1],P[0])/(P[0],P[0])*P[0] = x

P[2]=f[2]-(f[2],P[0])/(P[0],P[0])*P[0]-(f[2],P[1])/(P[1],P[1])*P[1] = x^2-1/3

P[3]=f[3]-(f[3],P[0])/(P[0],P[0])*P[0]-(f[3],P[1])/(P[1],P[1])*P[1]-(f[3],P[2])/(P[2],P[2])*P[2] = x^3-(3/5)x

P[4]=f[4]-(f[4],P[0])/(P[0],P[0])*P[0]-(f[4],P[1])/(P[1],P[1])*P[1]-(f[4],P[2])/(P[2],P[2])*P[2]-(f[4],P[3])/(P[3],P[3])*P[3] = x^4-(6/7)x^2+3/35

.

.

.

P[n]=f[n]-(f[n],P[0])/(P[0],P[0])*P[0]-(f[n],P[1])/(P[1],P[1])*P[1]-...-(f[n],P[i])/(P[i],P[i])*P[i]-...-(f[n],P[n-1])/(P[n-1],P[n-1])*P[n-1]

 

where in general, (f[k],P[i])/(P[i],P[i])*P[i] = (int(f[k]*P[i], x = -1 .. 1))/(int(P[i]*P[i], x = -1 .. 1))*P[i], for all i=0,1,2,...,k-1 and some k among 1, 2, ... , n.


ie. the inner product  (p,q)= int(p(x)*q(x), x = -1 .. 1).

 

Thanks,

Brad

Page 1 of 1