Question

2. Legrendre polynomials are sometimes used in applied mathematics. The first 3 Legrendre polynomials are: , Pi(x)-x, P2(x) = 2 For i> 2 subsequent Legrendre polynomials may be generated by the following formula: Pi = (2 * i-1) * x *P1-(i-1)*P-2 Let x = 0.66. Using VBA, calculate P2 through P10 using a For loop. Begin with and turn in a owchart with your solution.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

VBA Code:

Public Function Legendre(n As Integer, x As Double) As Double
'Computes the nth Legendre polynomial given x

Dim Pn As Double, Pn_1 As Double, Pn_2 As Double
Dim j As Integer
If n < 0 Then
MsgBox "n must be >= 0. Error"
Legendre = 0
Exit Function
End If
'P0 is 1 and P1 is x.
If n = 0 Then
Pn = 1
ElseIf n = 1 Then
Pn = x
Else 'n >= 2
Pn_1 = 1
Pn = x
For j = 2 To n
Pn_2 = Pn_1
Pn_1 = Pn
Pn = (((2 * j - 1) * x * Pn_1) - ((j - 1) * Pn_2)) / j
Next j
End If
Legendre = Pn
End Function

Flowchart:

Function execution results:

Description:

As stated in the problem using values from P0(X), P1(X) and formula for  Legendre equation used a for loop to implement the value assignment for Pn(X) and displayed the results.

Add a comment
Know the answer?
Add Answer to:
2. Legrendre polynomials are sometimes used in applied mathematics. The first 3 Legrendre polynomials are: ,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Let P2 be the vector space of polynomials of lower or equal degree at 2 with the scalar product: ...

    Let P2 be the vector space of polynomials of lower or equal degree at 2 with the scalar product: Let p1 (x) = 1 and p2 (x) = 2x - 1, two polynomials of P2. 1) Show that B = {p1, p2} forms an orthogonal set of P2. 2) Complete B to get a P2 base. 3) Let W = Vect {p1 (x), p2 (x)} be a vector subspace of P2, to determine W ⊥. Ensembles orthogonaux et bases orthogonales...

  • 3. Let Po(x) respectively. Find the monic Legendre polynomials of degree 2, 3 and 4 using...

    3. Let Po(x) respectively. Find the monic Legendre polynomials of degree 2, 3 and 4 using the orthogonality relation f P(x)Pm(x)dx = 0, mn and m,n E N. 1 and P1(x) = x be two Legendre polynomials of degree 0 and 1, 3. Let Po(x) respectively. Find the monic Legendre polynomials of degree 2, 3 and 4 using the orthogonality relation f P(x)Pm(x)dx = 0, mn and m,n E N. 1 and P1(x) = x be two Legendre polynomials of...

  • (1) We define an inner product on polynomials by (p(x), g(x) = } p(a)(ar)dx. d doc...

    (1) We define an inner product on polynomials by (p(x), g(x) = } p(a)(ar)dx. d doc Compute the adjoint of the transformation : P2(R) + P1(R) using two different methods: (a) Coordinate-free: use the definition of the adjoint, d (P(x)), dx dx (b) Using coordinates: find the matrix of in terms of orthonormal bases for P2(R) and P1(R), take the transpose, and then translate back into polynomials. For example, you may use the orthonormal polynomials we found in Zoom question...

  • 2. Consider the polynomials 0-k (z) := (1 + z) for k-0,..., 10 and let B-bo,b1bo) can be shown th...

    2. Consider the polynomials 0-k (z) := (1 + z) for k-0,..., 10 and let B-bo,b1bo) can be shown that B is a basis for Pio the vector space of polynomials of degree at most 10. (You do not need to prove this.) Let Pk (z)-rk for k = 0, 1, . . . , 10, so that S = {po, pi, . . . , pio) is the standard basis for P10. Use Mathematica to: (a) Compute the change...

  • ring over Q in countably many variables. Let I be the ideal of R generated by all polynomials -Pi where p; is the ith prime. Let RnQ1,2, 3, n] be the polyno- mial ring over Q in n variables. Let...

    ring over Q in countably many variables. Let I be the ideal of R generated by all polynomials -Pi where p; is the ith prime. Let RnQ1,2, 3, n] be the polyno- mial ring over Q in n variables. Let In be the ideal of Rn generated by all ] be the polynomial rin 9. Let R = QlX1,22.Zg, 2 polynomials -pi, where pi is the ith prime, for i1,.,n. . Show that each Rn/In is a field, and that...

  • Let P3 be the vector space of all polynomials of degree 3 or less. Let S...

    Let P3 be the vector space of all polynomials of degree 3 or less. Let S = {p1 (t), p2(t), p3 (t), p4(t)}, Q = span{pı(t), p2(t), P3 (t), p4(t)}, where pi(t) =1+3+ 2+2 – †, P2(t) = t +ť, P3(t) = t +ť? – ť, p4(t) = 3 + 8t+8+3. The basis B of Q chosen from the set S is given by: Select one alternative: O pi(t), p2(t), pä(t) Opı(t), p3(t), p4(t) O pi(t), p2(t), pä(t), p4(t) O...

  • Q3. Consider the vector space P, consisting of all polynomials of degree at most two together...

    Q3. Consider the vector space P, consisting of all polynomials of degree at most two together with the zero polynomial. Let S = {p.(t), p2(t)} be a set of polynomials in P, where: pi(t) = -4 +5, po(t) = -3° - 34+5 (a) Determine whether the set S = {P1(t).pz(t)} is linearly independent in Py? Provide a clear justification for your solution. (8 pts) (b) Determine whether the set S = {p(t),p2(t)} spans the vector space P ? Provide a...

  • 7. Let V = P2-{polynomials in x of degree 2 on the interval o <エく1) and...

    7. Let V = P2-{polynomials in x of degree 2 on the interval o <エく1) and let H span(1,2}, Find the vector in H (i.e., the linear function) that is closest to a2 in the sense of the distance

  • MATEMATIK MATHEMATICS 5 Polinomlar Polynomials 1. P(x)-(a-b-4)/x+(a+b-12)x1+6x+4 5. 2 Yant/ Answe...

    MATEMATIK MATHEMATICS 5 Polinomlar Polynomials 1. P(x)-(a-b-4)/x+(a+b-12)x1+6x+4 5. 2 Yant/ Answer 32 2. Px)-(a-2(a+b-8)x2+4x-7 6. Yanit / Answer: 12 12 7 MATEMATIK MATHEMATICS 5 Polinomlar Polynomials 1. P(x)-(a-b-4)/x+(a+b-12)x1+6x+4 5. 2 Yant/ Answer 32 2. Px)-(a-2(a+b-8)x2+4x-7 6. Yanit / Answer: 12 12 7

  • 3. Use the recurrence relation to obtain ex ,P(x),P,(z),B(x), assuming that P)(z) = i. Pi (x)-z. ...

    3. Use the recurrence relation to obtain ex ,P(x),P,(z),B(x), assuming that P)(z) = i. Pi (x)-z. Then sketch the graphs of P,.(x) for n-0. Î,2.3.4.5 İn the interval-1-z-i in one Figure. You may use any software to produce the graphs. pressions for the Legendre polynomials P2(r) 3. Use the recurrence relation to obtain ex ,P(x),P,(z),B(x), assuming that P)(z) = i. Pi (x)-z. Then sketch the graphs of P,.(x) for n-0. Î,2.3.4.5 İn the interval-1-z-i in one Figure. You may use...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT