Legendre polynomials in the reverse direction

In summary, the programmer has written a program to calculate Legendre Polynomials. The first section of the problem is to find the recursive polynomial in the forward direction. The next section of the problem is to investigate the recursive polynomial in the reverse direction. However, the programmer has not found a mistake or bug in the program. All seems good. However, what the programmer expects in the reverse direction is to get the P value for l=1, which is always x. The programmer has spent hours with the debugger and pouring over the code, but has not found the bug or mistake. Help is needed.
  • #1
ognik
643
2
I have just written a program to calculate Legendre Polynomials, finding for Pl+1 using the recursion (l+1)Pl+1 + lPl-1 - (2l+1).x.Pl=0 That is working fine.
The next section of the problem is to investigate the recursive polynomial in the reverse direction. I would solve this for Pl-1 in terms of Pl and Pl+1 - could someone please confirm if that is the correct way to 'reverse'? Also I would use the Rodriques formula to get the 2 starting values of Pn and Pn-1, it's a complex formula, is there a better way to get those starting values? Thanks for all help.
 
Physics news on Phys.org
  • #2
Hi again - I found enough to convince me that solving for Pl-1 is the correct way to calculate in the reverse direction. I also decided against using the Rodriguez formula, since I work out Pl and Pl+1 in the forward program, I can just use those as starting values for the reverse direction. All seemed good. However what I expect in the reverse direction, is to get P(x) for l=1, which should be always x. I figured that the last 2 P values correspond to L_input and L_input - 1, so loop down from L_input - 2 down to l=1 - see program code below.
I have spent hours with the debugger and pouring over the code, can't spot the bug or mistake in approach. Help please?
Code:
program LegendreDual
   implicit none
   integer, parameter   ::   rep=60
   integer, parameter   ::   dp = selected_real_kind(15, 307)
   real(kind=dp)     ::   X,P,P_minus,P_plus,saveP
   integer         ::   j, L_input
   character(len=rep )   ::   stars=REPEAT('*',rep)
   !----- header ----   
   print *, " "
   print *, 'Program LegendreDual starts'
   print *, stars 
   !----- Initialise ----   
   print *, " "
   print *,'Enter  l, X (l .LT.  0 to stop)'
   read *, L_input, X
   print *, " "
  while (L_input.GE.0) do
       print 20, 'L input','X Input','P'
     If (L_input.EQ.0) then
     P=0
  else if (L_input.EQ.1) then
       P=X
  else
     P_minus=1
  P=X
  Do j=1, L_input-1,+1           ! loop for fwd recursion
     P_plus=(((2*j)+1)*X*P)-(j*P_minus)
     P_plus=P_plus/(j+1)
         saveP=P
     P_minus=P                 ! roll values
     P=P_plus
       end do
     Print 50, L_input, X, P   
  P=saveP                   ! P from fwd; we can use P_plus and P
!-----------------------               ! to start the backward recursion
      Do j=L_input-2,1,-1               ! loop for reverse recursion,
     P_minus=(((2*j)+1)*X*P)-((j+1)*P_plus)   ! using P(n+1) and P just found
     P_minus=P_minus/j
     P=P_minus                   ! roll values
     P_plus=P
       end do     
  end if
  Print 50, j, X, P             ! only print once if l=0 or 1
     print *, stars  
     print *, " "
     print *,'Enter  l, X (l .LT.  0 to stop)'
     read *, L_input, X
  end do
   print *, " "
!--- admin ----
   print *, 'User selected end'
   print *, stars  
20   format (3X, A, 3X, A, 18X,A)
50   format (3X, I3, 5X, F10.5, 5X, F25.5)
end program LegendreDual
 
  • #3
Please feel free to close or delete this thread and sorry for any inconvenience
 

1. What are Legendre polynomials in the reverse direction?

Legendre polynomials are a type of mathematical function that is commonly used in physics and engineering to solve differential equations and represent physical phenomena. In the reverse direction, Legendre polynomials are evaluated from high to low degree, as opposed to the traditional low to high degree.

2. How are Legendre polynomials in the reverse direction different from regular Legendre polynomials?

The main difference between Legendre polynomials in the reverse direction and regular Legendre polynomials is the order in which they are evaluated. Reverse Legendre polynomials start from the highest degree and work their way down, while regular Legendre polynomials start from the lowest degree and work their way up.

3. What applications use Legendre polynomials in the reverse direction?

Reverse Legendre polynomials are commonly used in signal processing, image reconstruction, and function approximation. They can also be applied in quantum mechanics and computational fluid dynamics.

4. How are Legendre polynomials in the reverse direction calculated?

Reverse Legendre polynomials can be calculated using recurrence relations or through the use of generating functions. They can also be calculated using numerical methods such as Gauss-Legendre quadrature.

5. What are the properties of Legendre polynomials in the reverse direction?

Like regular Legendre polynomials, reverse Legendre polynomials have the properties of orthogonality, completeness, and recursion. They also have the property of symmetry, where Pn(x) = (-1)n Pn(-x).

Similar threads

  • Advanced Physics Homework Help
Replies
1
Views
1K
  • Topology and Analysis
Replies
1
Views
2K
  • Topology and Analysis
Replies
2
Views
1K
  • Calculus
Replies
15
Views
3K
Replies
1
Views
3K
Replies
1
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
941
  • Advanced Physics Homework Help
Replies
3
Views
1K
  • General Math
Replies
1
Views
1K
  • Calculus and Beyond Homework Help
Replies
2
Views
1K
Back
Top