1 | function vp = p_polynomial_prime ( m, n, x )
|
---|
2 |
|
---|
3 | %*****************************************************************************80
|
---|
4 | %
|
---|
5 | %% P_POLYNOMIAL_PRIME evaluates the derivative of Legendre polynomials P(n,x).
|
---|
6 | %
|
---|
7 | % Discussion:
|
---|
8 | %
|
---|
9 | % P(0,X) = 1
|
---|
10 | % P(1,X) = X
|
---|
11 | % P(N,X) = ( (2*N-1)*X*P(N-1,X)-(N-1)*P(N-2,X) ) / N
|
---|
12 | %
|
---|
13 | % P'(0,X) = 0
|
---|
14 | % P'(1,X) = 1
|
---|
15 | % P'(N,X) = ( (2*N-1)*(P(N-1,X)+X*P'(N-1,X)-(N-1)*P'(N-2,X) ) / N
|
---|
16 | %
|
---|
17 | % Licensing:
|
---|
18 | %
|
---|
19 | % This code is distributed under the GNU LGPL license.
|
---|
20 | %
|
---|
21 | % Modified:
|
---|
22 | %
|
---|
23 | % 13 March 2012
|
---|
24 | %
|
---|
25 | % Author:
|
---|
26 | %
|
---|
27 | % John Burkardt
|
---|
28 | %
|
---|
29 | % Reference:
|
---|
30 | %
|
---|
31 | % Milton Abramowitz, Irene Stegun,
|
---|
32 | % Handbook of Mathematical Functions,
|
---|
33 | % National Bureau of Standards, 1964,
|
---|
34 | % ISBN: 0-486-61272-4,
|
---|
35 | % LC: QA47.A34.
|
---|
36 | %
|
---|
37 | % Daniel Zwillinger, editor,
|
---|
38 | % CRC Standard Mathematical Tables and Formulae,
|
---|
39 | % 30th Edition,
|
---|
40 | % CRC Press, 1996.
|
---|
41 | %
|
---|
42 | % Parameters:
|
---|
43 | %
|
---|
44 | % Input, integer M, the number of evaluation points.
|
---|
45 | %
|
---|
46 | % Input, integer N, the highest order polynomial to evaluate.
|
---|
47 | % Note that polynomials 0 through N will be evaluated.
|
---|
48 | %
|
---|
49 | % Input, real X(M,1), the evaluation points.
|
---|
50 | %
|
---|
51 | % Output, real VP(M,N+1), the values of the derivatives of the
|
---|
52 | % Legendre polynomials of order 0 through N at the point X.
|
---|
53 | %
|
---|
54 | if ( n < 0 )
|
---|
55 | vp = [];
|
---|
56 | return
|
---|
57 | end
|
---|
58 |
|
---|
59 | v = zeros ( m, n + 1 );
|
---|
60 | vp = zeros ( m, n + 1 );
|
---|
61 |
|
---|
62 | v(1:m,1) = 1.0;
|
---|
63 | vp(1:m,1) = 0.0;
|
---|
64 |
|
---|
65 | if ( n < 1 )
|
---|
66 | return
|
---|
67 | end
|
---|
68 |
|
---|
69 | v(1:m,2) = x(1:m,1);
|
---|
70 | vp(1:m,2) = 1.0;
|
---|
71 |
|
---|
72 | for i = 2 : n
|
---|
73 |
|
---|
74 | v(1:m,i+1) = ( ( 2 * i - 1 ) * x(1:m,1) .* v(1:m,i) ...
|
---|
75 | - ( i - 1 ) * v(1:m,i-1) ) ...
|
---|
76 | / ( i );
|
---|
77 |
|
---|
78 | vp(1:m,i+1) = ( ( 2 * i - 1 ) * ( v(1:m,i) + x(1:m,1) .* vp(1:m,i) ) ...
|
---|
79 | - ( i - 1 ) * vp(1:m,i-1) ) ...
|
---|
80 | / ( i );
|
---|
81 |
|
---|
82 | end
|
---|
83 |
|
---|
84 | return
|
---|
85 | end
|
---|