3 /* Rodrigue's formulae */
5 jacobi_p_rod(n,a,b,x) := block([ an, rho, g ],
6 an : (-1)^n * 2^n * n!,
7 rho : (1-t)^a * (1 + t)^b,
9 rat(subst(x,t, diff(rho * g^n,t,n) / (an * rho)))),
11 gen_laguerre_rod(n, a, x) := block([an, rho, g],
15 rat(subst(x,t, diff(rho * g^n,t,n) / (an * rho)))),
17 hermite_rod(n,x) := block([an, rho, g],
21 rat(subst(x,t, diff(rho * g^n,t,n) / (an * rho)))),
23 /*See A&S 10.1.25 page 439. */
25 spherical_bessel_j_rod(n,x) := block([sofar,k],
28 sofar : -diff(sofar,x) / x
32 spherical_bessel_y_rod(n,x) := block([sofar,k],
35 sofar : -diff(sofar,x) / x
39 all_functions : [jacobi_p,
63 check_zero_list(e) := block([ k, okay,n],
68 while okay and k < n do (
70 if not zerop(e[ k ]) then (
75 tests_pass : endcons(test_name, tests_pass),
76 print("okay: ", test_name)
78 print("error: ", test_name),
79 print("should vanish = ", e[ k ]),
80 errors_found : endcons(test_name, errors_found)
84 check_true_list(e) := block([ ],
85 if member(false, e) then (
86 print("error: ", test_name),
87 errors_found : endcons(test_name, errors_found)
89 tests_pass : endcons(test_name, tests_pass),
90 print("okay: ", test_name)
97 /* Jacobi Rodrigues test*/
99 (test_name : "Jacobi Rodrigues test",
100 foo : makelist(jacobi_p(k,a,b,x) - jacobi_p_rod(k,a,b,x), k,0,5),
102 check_zero_list(foo));
105 /* gen_laguerre Rodrigues*/
107 (test_name : "gen_laguerre Rodrigues",
108 foo : makelist(gen_laguerre(k,a,x) - gen_laguerre_rod(k,a,x), k,0,5),
110 check_zero_list(foo));
113 /* hermite Rodrigues*/
115 (test_name : "hermite Rodrigues",
116 foo : makelist(hermite(k,x) - hermite_rod(k,x), k,0,5),
118 check_zero_list(foo));
121 /* spherical_bessel_j Rodrigues*/
123 (test_name : "spherical_bessel_j Rodrigues",
124 foo : makelist(spherical_bessel_j(k,x) - spherical_bessel_j_rod(k,x), k,0,5),
125 foo : ratsimp(exponentialize(foo)),
126 check_zero_list(foo));
129 /* spherical_bessel_y Rodrigues*/
131 (test_name : "spherical_bessel_y Rodrigues",
132 foo : makelist(spherical_bessel_y(k,x) - spherical_bessel_y_rod(k,x), k,0,5),
133 foo : ratsimp(exponentialize(foo)),
134 check_zero_list(foo));
140 (test_name : "spherical harmonic orthogonality",
143 f(n1,m1,n2,m2) := defint(defint(trigreduce(spherical_harmonic(n1,m1,th,ph) *
144 conjugate(spherical_harmonic(n2,m2,th,ph)) * sin(th)),th,0,%pi),ph,0,2*%pi),
147 for n1 : 0 thru 2 do (
148 for m1 : -n1 thru n1 do (
149 for n2 : 0 thru 2 do (
150 for m2 : - n2 thru n2 do (
151 sofar : cons(f(n1,m1,n2,m2) - kron_delta(n1,n2) * kron_delta(m1,m2), sofar)
156 check_zero_list(sofar));
162 /* See A&S 22.3.14 page 776 and 22.5.4 page 777.
165 (test_name : "A&S 22.3.14",
167 foo : makelist(ultraspherical(n,a,cos(x))/a - 2*cos(n*x)/n,n,1, 3),
168 foo : limit(foo,a,0),
169 foo : ratsimp(trigreduce(foo)),
170 check_zero_list(foo));
173 /* See A&S 22.3.14 page 776
176 (test_name : "A&S 22.3.14",
178 foo : makelist(chebyshev_t(n,cos(x)) - cos(n*x),n,0, 3),
179 foo : ratsimp(trigreduce(foo)),
180 check_zero_list(foo));
183 /* See A&S 22.3.15 page 776
186 (test_name : "A&S 22.3.15",
188 foo : makelist(sin(x) * chebyshev_u(n,cos(x)) - sin((n+1)*x),n,0, 4),
189 foo : ratsimp(trigreduce(foo)),
190 check_zero_list(foo));
193 /* See A&S 22.7.15 page 782.
196 (test_name : "A&S 22.7.15",
198 jacobi_rec(n) := (n + a/2+b/2+1)*(1-x)*jacobi_p(n,a+1,b,x)
199 - (n+a+1)*jacobi_p(n,a,b,x) + (n+1)*jacobi_p(n+1,a,b,x),
201 check_zero_list(makelist(ratsimp(jacobi_rec(n)),n,0, 7)));
204 /* See A&S 22.7.16 page 782
207 (test_name : "A&S 22.7.16",
209 jacobi_rec(n) := (n + a/2+b/2+1)*(1+x)*jacobi_p(n,a,b+1,x)
210 - (n+b+1)*jacobi_p(n,a,b,x) - (n+1)*jacobi_p(n+1,a,b,x),
212 check_zero_list(makelist(ratsimp(jacobi_rec(n)),n,0, 7)));
215 /* See A&S 22.7.17 page 782
218 (test_name : "A&S 22.7.17",
220 jacobi_rec(n) := (1-x)*jacobi_p(n,a+1,b,x)
221 + (1+x)*jacobi_p(n,a,b+1,x) - 2*jacobi_p(n,a,b,x),
223 check_zero_list(makelist(ratsimp(jacobi_rec(n)),n,0, 7)));
226 /* See A&S 22.7.18 page 782
229 (test_name : "A&S 22.7.18",
231 jacobi_rec(n) := (2*n+a+b)*jacobi_p(n,a-1,b,x)
232 - (n+a+b)*jacobi_p(n,a,b,x) + (n+b)*jacobi_p(n-1,a,b,x),
234 check_zero_list(makelist(ratsimp(jacobi_rec(n)),n,1, 7)));
237 /* See A&S 22.7.19 page 782
240 (test_name : "A&S 22.7.19",
242 jacobi_rec(n) := (2*n+a+b)*jacobi_p(n,a,b-1,x)
243 - (n+a+b)*jacobi_p(n,a,b,x) - (n+a)*jacobi_p(n-1,a,b,x),
245 check_zero_list(makelist(ratsimp(jacobi_rec(n)),n, 1, 7)));
248 /* See A&S 22.7.20 page 782
251 (test_name : "A&S 22.7.20",
253 jacobi_rec(n) := jacobi_p(n,a,b-1,x)
254 - jacobi_p(n,a-1,b,x) - jacobi_p(n-1,a,b,x),
256 check_zero_list(makelist(ratsimp(jacobi_rec(n)),n,1, 2)));
259 /* See A&S 22.7.21 page 782
262 (test_name : "A&S 22.7.21",
264 ultraspherical_rec(n) := 2*a*(1-x^2)*ultraspherical(n-1,a+1,x)
265 - (2*a+n-1) * ultraspherical(n-1,a,x) + n*x*ultraspherical(n,a,x),
267 foo : makelist(ratsimp(ultraspherical_rec(n)),n,1, 7),
268 foo : append(ev(foo,a=4/5), ev(foo, a= -2/3), ev(foo, a=8)),
269 check_zero_list(foo));
273 /* See A&S 22.7.23 page 782; funny 22.7.22 is missing a lhs.
274 Maxima lacks simplification rules to simplify linear
275 combinations of gamma functions.
278 (test_name : "A&S 22.7.23",
280 ultraspherical_rec(n) := (n+a)*ultraspherical(n+1,a-1,x)
281 - (a-1) * (ultraspherical(n+1,a,x) - ultraspherical(n-1,a,x)),
283 foo : makelist(ratsimp(ultraspherical_rec(n)),n,1, 7),
284 foo : append(ev(foo,a=4/5,rat), ev(foo, a=8,rat)),
285 check_zero_list(foo));
289 /* See A&S 22.7.24 page 782
292 (test_name : "A&S 22.7.24",
294 cheb_rec(n,m) := 2 * chebyshev_t(m,x) * chebyshev_t(n,x)
295 - chebyshev_t(n+m,x) - chebyshev_t(n-m,x),
297 foo : makelist(makelist(cheb_rec(n, m), m,1,n),n,1, 9),
299 foo : apply(append,foo),
300 check_zero_list(foo));
304 /* See A&S 22.7.25 page 782
307 (test_name : "A&S 22.7.25",
309 cheb_rec(n,m) := 2*(x^2-1)*chebyshev_u(m-1,x) * chebyshev_u(n-1,x)
310 - chebyshev_t(n+m,x) + chebyshev_t(n-m,x),
312 foo : makelist(makelist(cheb_rec(n, m), m,1,n),n,1, 9),
314 foo : apply(append,foo),
315 check_zero_list(foo));
319 /* See A&S 22.7.26 page 782
322 (test_name : "A&S 22.7.26",
324 cheb_rec(n,m) := 2*chebyshev_t(m,x) * chebyshev_u(n-1,x)
325 -chebyshev_u(n+m-1,x) - chebyshev_u(n-m-1,x),
327 foo : makelist(makelist(cheb_rec(n, m), m, 0, n-1),n,1, 9),
329 foo : apply(append,foo),
330 check_zero_list(foo));
333 /* See A&S 22.7.27 page 782
336 (test_name : "A&S 22.7.27",
338 cheb_rec(n,m) := 2*chebyshev_t(n,x) * chebyshev_u(m-1,x)
339 -chebyshev_u(n+m-1,x) + chebyshev_u(n-m-1,x),
341 foo : makelist(makelist(cheb_rec(n, m), m,1,n-1),n, 2, 10),
343 foo : apply(append,foo),
344 check_zero_list(foo));
347 /* See A&S 22.7.28 page 782
350 (test_name : "A&S 22.7.28",
352 cheb_rec(n) := 2*chebyshev_t(n,x) * chebyshev_u(n-1,x)
353 -chebyshev_u(2*n-1,x),
355 foo : makelist(cheb_rec(n), n,2,10),
357 check_zero_list(foo));
360 /* See A&S 22.7.29 page 783
363 (test_name : "A&S 22.7.29",
365 lag_rec(n) := gen_laguerre(n,1/3+1,x) -((x-n) * gen_laguerre(n,1/3,x) + (1/3+n) * gen_laguerre(n-1,1/3,x))/x,
366 check_zero_list(ratsimp(makelist(lag_rec(n),n,1, 10))));
369 (lag_rec(n) := gen_laguerre(n,5+1,x) -((x-n) * gen_laguerre(n,5,x) + (5+n) * gen_laguerre(n-1,5,x))/x,
370 check_zero_list(ratsimp(makelist(lag_rec(n),n,1,10))));
373 (lag_rec(n) := gen_laguerre(n,1,x) -((x-n) * gen_laguerre(n,0,x) + (n) * gen_laguerre(n-1,0,x))/x,
374 check_zero_list(ratsimp(makelist(lag_rec(n),n,1,10))));
378 /* See A&S 22.7.30 page 783
381 (test_name : "A&S 22.7.30",
385 lag_rec(n) := gen_laguerre(n,a-1,x) - gen_laguerre(n,a,x) + gen_laguerre(n-1,a,x),
387 check_zero_list(ratsimp(makelist(lag_rec(n),n,1, 10))));
393 /* See A&S 22.7.31 page 783
396 (test_name : "A&S 22.7.31",
398 lag_rec(n) := gen_laguerre(n,a+1,x) - (n+a+1)*gen_laguerre(n,a,x) / x + (n+1)*gen_laguerre(n+1,a,x)/x,
399 check_zero_list(ratsimp(makelist(lag_rec(n),n,0, 7))));
402 /* See A&S 22.7.32 page 783
405 (test_name : "A&S 22.7.32",
407 lag_rec(n) := gen_laguerre(n,a-1,x) - (n+1)*gen_laguerre(n+1,a,x) / (n+a) + (n+1-x)*gen_laguerre(n,a,x)/(n+a),
408 check_zero_list(ratsimp(makelist(lag_rec(n),n,0,7))));
411 /* See A&S 22.2.1 page 774
414 (test_name : "A&S 22.2.1",
416 f(a,b,n,m) := integrate((1-x)^a*(1+x)^b * jacobi_p(n,a,b,x)
417 * jacobi_p(m,a,b,x),x,-1,1),
418 foo : makelist(makelist(f(1/2,-1/2,n,m), n, 0, m - 1), m, 1, 5),
419 foo : apply(append,foo),
420 check_zero_list(foo));
423 (foo : makelist(makelist(f(1/3,2/3,n,m), n, 0, m - 1), m, 1, 5),
424 foo : apply(append,foo),
425 check_zero_list(foo));
429 (test_name : "jacobi normalization",
431 stand(n) := expand(jacobi_p(n,a,b,1) - binomial(n+a,n)),
432 check_zero_list(makelist(stand(n),n,0, 7)));
435 (test_name : "A&S 22.2.3",
438 baz(n,m) := 'integrate((1-x^2)^(a-1/2) * ultraspherical(n,a,x)* ultraspherical(m,a,x),x,-1,1),
439 foo : makelist(makelist(ev(baz(n,m),integrate),n,0,m-1),m,1, 2),
442 foo : apply(append,foo),
443 check_zero_list(foo));
446 /* See A&S 22.2.3 page 774; Maxima doesn't know enough about
447 the gamma functions to simplify these expressions to zero.
450 (test_name : "A&S 22.2.3",
452 stand(n) := ultraspherical(n,a,1) - binomial(n+2*a-1,n),
453 foo : makelist(stand(n),n,0, 7),
454 foo : append(ev(foo,a=2/3), ev(foo, a=7), ev(foo,a=1/3)),
456 check_zero_list(foo));
459 /* See A&S 22.2.10 page 774
462 (test_name : "A&S 22.2.10",
464 f(n,m) := integrate(legendre_p(n,(rat(x))) * legendre_p(m,rat(x)),x,-1,1) - kron_delta(n,m) * 2 /(2*n+1),
465 foo : makelist(makelist(f(n,m),n,0,3),m,0,3),
466 foo : apply(append, foo),
467 check_zero_list(foo));
470 (test_name : "legendre poly normalization",
471 stand(n) := legendre_p(n,1) -1,
472 foo : makelist(stand(n),n,0,35),
473 check_zero_list(foo));
476 /* See A&S 22.2.12 page 774
479 (test_name : "A&S 22.2.12",
480 baz(n,m) := 'integrate(gen_laguerre(n,a,x) * gen_laguerre(m,a,x) * exp(-x)*x^a,x,0,inf) - kron_delta(n,m) * gamma(a+n+1)/n!,
481 foo : makelist(makelist(baz(n,m),n,0,5),m,0,5),
482 foo : apply(append, ev(foo,a=2/3, integrate)),
483 check_zero_list(foo));
487 /* See A&S 22.2.13 page 775
490 (test_name : "A&S 22.2.13",
491 baz(n,m) := 'integrate(laguerre(n,x) * laguerre(m,x) * exp(-x),x,0,inf) - kron_delta(n,m),
492 foo : makelist(makelist(ev(baz(n,m), integrate), n,0,4),m,0,4),
494 foo : apply(append, foo),
495 check_zero_list(foo));
498 /* See A&S 22.2.14 page 775
501 (test_name : "A&S 22.2.14",
502 baz(n,m) := 'integrate(hermite(n,x) * hermite(m,x) * exp(-x^2),x,-inf,inf) - kron_delta(n,m) * sqrt(%pi) * 2^n * n!,
503 foo : makelist(makelist(ev(baz(n,m), integrate), n,0,4),m,0,4),
504 foo : apply(append, foo),
505 check_zero_list(foo));
509 /* Some Christoffel-Darboux sum formulae
512 /* See A&S 22.12.2 page 785
515 (test_name : "A&S 22.12.2",
516 baz(n) := sum(chebyshev_t(2*k,x) ,k,0,n) - (1 + chebyshev_u(2*n,x))/2,
517 foo : makelist(rat(baz(n)),n,0,7),
518 check_zero_list(foo));
521 /* See A&S 22.12.3 page 785
524 (test_name : "A&S 22.12.3",
525 baz(n) := sum(chebyshev_t(2*k+1,x) ,k,0,n-1) - chebyshev_u(2*n-1,x)/2,
526 foo : makelist(rat(baz(n)),n,1, 7),
527 check_zero_list(foo));
530 /* See A&S 22.12.4 page 785
533 (test_name : "A&S 22.12.4",
534 baz(n) := sum(chebyshev_u(2*k,x) ,k,0,n) - (1-chebyshev_t(2*n+2,x))/(2 * (1-x^2)),
535 foo : makelist(rat(baz(n)),n,1, 11),
536 check_zero_list(foo));
539 /* See A&S 22.2.12.5 page 785
542 (test_name : "A&S 22.12.5",
543 baz(n) := sum(chebyshev_u(2*k+1,x) ,k,0,n-1) - (x-chebyshev_t(2*n+1,x))/(2 * (1-x^2)),
544 foo : makelist(rat(baz(n)),n,1,7),
545 check_zero_list(foo));
548 /* See A&S 22.12.6 page 785
551 (test_name : "A&S 22.12.6",
552 baz(n) := gen_laguerre(n,a+b+1,x+y) - sum(gen_laguerre(k,a,x) * gen_laguerre(n-k,b,y),k,0,n),
553 foo : makelist(rat(baz(n)),n,1, 7),
554 check_zero_list(foo));
557 /* See A&S 22.12.7 page 785
560 (test_name : "A&S 22.12.7",
561 baz(n) := gen_laguerre(n,a,x*y) -
562 sum(binomial(n+a,m) * y^(n-m) * (1-y)^m * gen_laguerre(n-m,a,x),m,0,n),
563 foo : makelist(rat(baz(n)),n,1,3),
564 check_zero_list(foo));
567 /* See A&S 22.12.8 page 785
570 (test_name : "A&S 22.12.8",
571 baz(n) := hermite(n,x+y) - sum(binomial(n, k) * hermite(k,sqrt(2)*x) * hermite(n-k,sqrt(2)*y),k,0,n) / 2^(n/2),
572 foo : makelist(rat(baz(n)),n,0, 7),
573 check_zero_list(foo));
576 /* See A&S 22.5.17 page 778
579 (test_name : "A&S 22.5.17",
580 baz(n,m) := gen_laguerre(n,m,x) - (-1)^m * diff(laguerre(n+m,x),x,m),
581 foo : makelist(makelist(baz(i,j),j,0,i),i,0,7),
583 foo : apply(append,foo),
584 check_zero_list(foo));
587 /* See A&S 22.7.29 page 783
590 (test_name : "A&S 22.7.29",
591 baz(n) := gen_laguerre(n,a+1,x) - ((x-n)*gen_laguerre(n,a,x) + (a+n)*gen_laguerre(n-1,a,x))/x,
592 foo : makelist(baz(i),i,1,8),
594 check_zero_list(foo));
600 (test_name : "A&S 22.12.2 - float",
601 orthopoly_returns_intervals : true,
604 xargs(e) := if intervalp(e) then args(e) else [e,0],
606 f(n,x) := block([p,q],
607 p : sum(xargs(chebyshev_t(2*i,x)),i,0,n),
608 q : xargs(chebyshev_u(2*n,x)) / 2,
609 [part(p,1) - part(q,1), part(p,2) + part(q,2)]),
612 for i : -50 thru 50 do (
613 foo : f(10, 1.25 * i),
616 if (abs(foo - 0.5) <= e) then foo : 0 else foo : 1,
617 gomer : cons(foo, gomer)),
618 check_zero_list(gomer));
622 for i : -100 thru 100 do (
623 foo : f(35, 0.01 * i),
626 if (abs(foo - 0.5) <= e) then foo : 0 else foo : 1,
627 gomer : cons(foo, gomer)),
628 check_zero_list(gomer));
632 for i : 1 thru 100 do (
633 foo : f(35, -0.01 * i),
636 if (abs(foo - 0.5) <= e) then foo : 0 else foo : 1,
637 gomer : cons(foo, gomer)),
638 check_zero_list(gomer));
642 for i : -100 thru 100 do (
643 foo : f(35, 0.01 * i + %i * 0.2),
646 if (abs(foo - 0.5) <= e) then foo : 0 else foo : 1,
647 gomer : cons(foo, gomer)),
648 check_zero_list(gomer));
652 for i : -100 thru 100 do (
653 foo : f(36, -0.01 * i + %i * 0.2),
656 if (abs(foo - 0.5) <= e) then foo : 0 else foo : 1,
657 gomer : cons(foo, gomer)),
658 check_zero_list(gomer));
661 (test_name : "A&S 22.12.3 - float",
663 f(n,x) := block([p,q],
664 p : sum(xargs(chebyshev_t(2*i+1,x)),i,0,n-1),
665 q : xargs(chebyshev_u(2*n-1,x)) / 2,
666 [part(p,1) - part(q,1), part(p,2) + part(q,2)]),
670 for i : -50 thru 50 do (
671 foo : f(10, 1.25 * i),
674 if (abs(foo) <= e) then foo : 0 else foo : 1,
675 gomer : cons(foo, gomer)),
676 check_zero_list(gomer));
680 for i : -100 thru 100 do (
681 foo : f(35, 0.01 * i),
684 if (abs(foo) <= e) then foo : 0 else foo : 1,
685 gomer : cons(foo, gomer)),
686 check_zero_list(gomer));
690 for i : 1 thru 100 do (
691 foo : f(35, -0.01 * i),
694 if (abs(foo) <= e) then foo : 0 else foo : 1,
695 gomer : cons(foo, gomer)),
696 check_zero_list(gomer));
700 for i : -100 thru 100 do (
701 foo : f(35, 0.01 * i + %i * 0.2),
704 if (abs(foo) <= e) then foo : 0 else foo : 1,
705 gomer : cons(foo, gomer)),
706 check_zero_list(gomer));
710 for i : -100 thru 100 do (
711 foo : f(36, -0.01 * i + %i * 0.2),
714 if (abs(foo) <= e) then foo : 0 else foo : 1,
715 gomer : cons(foo, gomer)),
716 check_zero_list(gomer));
720 (test_name : "G&R 8.974-3-float",
722 f(n,a,x) := block([p,q],
723 p : sum(xargs(gen_laguerre(i,a,x)),i,0,n),
724 q : xargs(gen_laguerre(n,a+1,x)),
725 [part(p,1) - part(q,1), part(p,2) + part(q,2)]),
728 for i : -100 thru 100 do (
729 foo : f(11,0.4, float(0.01 * i)),
732 if (abs(foo) <= e) then foo : 0 else foo : 1,
733 gomer : cons(foo,gomer)),
734 check_zero_list(gomer));
738 for i : -100 thru 100 do (
739 foo : f(12,0.4, float(0.01 * i)),
742 if (abs(foo) <= e) then foo : 0 else foo : 1,
743 gomer : cons(foo,gomer)),
744 check_zero_list(gomer));
748 for i : -100 thru 100 do (
749 foo : f(12,-0.4, float(0.01 * i)),
752 if (abs(foo) <= e) then foo : 0 else foo : 1,
753 gomer : cons(foo,gomer)),
754 check_zero_list(gomer));
758 for i : -100 thru 100 do (
759 foo : f(12,-41.0, float(0.01 * i)),
762 if (abs(foo) <= e) then foo : 0 else foo : 1,
763 gomer : cons(foo,gomer)),
764 check_zero_list(gomer));
768 for i : -100 thru 100 do (
769 foo : f(12,-4.1, float(0.01 * i * %i)),
772 if (abs(foo) <= e) then foo : 0 else foo : 1,
773 gomer : cons(foo,gomer)),
774 check_zero_list(gomer));
777 (test_name : "random jacobi float",
780 for i : 1 thru 500 do (
782 a : random(11) / (1 + random(9)),
783 b : random(11) / (1 + random(9)),
784 x : (random(11) - 5) / (1 + random(10)),
785 exact : float(jacobi_p(n,a,b,x)),
786 approx : jacobi_p(n,float(a),float(b),float(x)),
787 if (abs(exact-part(approx,1)) <= part(approx,2)) then foo : 0 else foo : 1,
788 if (foo = 1) then print ("n = ",n, " a = ",a," b = ",b, "x = ",x),
789 gomer : cons(foo,gomer)),
790 check_zero_list(gomer));
793 (test_name : "random ultraspherical float",
796 for i : 1 thru 500 do (
798 a : random(11) / (1 + random(9)),
799 x : (random(11) - 5) / (1 + random(10)),
800 exact : float(ultraspherical(n,a,x)),
801 approx : ultraspherical(n,float(a),float(x)),
802 if (abs(exact-part(approx,1)) <= part(approx,2)) then foo : 0 else foo : 1,
803 if (foo = 1) then print ("n = ",n, " a = ",a,"x = ",x),
804 gomer : cons(foo,gomer)),
805 check_zero_list(gomer));
808 (test_name : "random chebyshev_t float",
810 for i : 1 thru 500 do (
812 x : (random(11) - 5) / (1 + random(10)),
813 exact : float(chebyshev_t(n,x)),
814 approx : chebyshev_t(n,float(x)),
815 if (abs(exact-part(approx,1)) <= part(approx,2)) then foo : 0 else foo : 1,
816 if (foo = 1) then print("chebyshev_t float error; n = ",n, "x = ",x),
817 gomer : cons(foo,gomer)),
818 check_zero_list(gomer));
821 (test_name : "random chebyshev_u float",
823 for i : 1 thru 500 do (
825 x : (random(11) - 5) / (1 + random(10)),
826 exact : float(chebyshev_u(n,x)),
827 approx : chebyshev_u(n,float(x)),
828 if (abs(exact-part(approx,1)) <= part(approx,2)) then foo : 0 else foo : 1,
829 if (foo = 1) then print("chebyshev_t float error; n = ",n, "x = ",x),
830 gomer : cons(foo,gomer)),
831 check_zero_list(gomer));
835 (test_name : "random legendre float",
837 for i : 1 thru 500 do (
839 x : (random(11) - 5) / (1 + random(10)),
840 exact : float(legendre_p(n,x)),
841 approx : legendre_p(n,float(x)),
842 if (abs(exact-part(approx,1)) <= part(approx,2)) then foo : 0 else foo : 1,
843 if (foo = 1) then print("legendre float error; n = ",n, "x = ",x),
844 gomer : cons(foo,gomer)),
845 check_zero_list(gomer));
848 (test_name : "random hermite float",
850 for i : 1 thru 500 do (
852 x : (random(11) - 5) / (1 + random(10)),
853 exact : float(hermite(n,x)),
854 approx : hermite(n,float(x)),
855 if (abs(exact-part(approx,1)) <= part(approx,2)) then foo : 0 else foo : 1,
856 if (foo = 1) then print("hermite float error; n = ",n, "x = ",x),
857 gomer : cons(foo,gomer)),
858 check_zero_list(gomer));
862 (test_name : "random gen_laguerre float",
865 for i : 1 thru 500 do (
867 a : random(11) / (1 + random(9)),
868 x : (random(11) - 5) / (1 + random(10)),
869 exact : float(gen_laguerre(n,a,x)),
870 approx : gen_laguerre(n,float(a),float(x)),
871 if (abs(exact-part(approx,1)) <= part(approx,2)) then foo : 0 else foo : 1,
872 if (foo = 1) then print ("n = ",n, " a = ",a," b = ",b, "x = ",x),
873 gomer : cons(foo,gomer)),
874 check_zero_list(gomer));
877 (test_name : "random assoc_legendre_p float",
879 for i : 1 thru 500 do (
882 x : (random(11) - 5)/ (1 + random(10)),
883 exact : float(assoc_legendre_p(n,m,x)),
884 approx : assoc_legendre_p(n,m,float(x)),
885 if not(intervalp(approx)) then approx : interval(approx,0),
886 if (abs(exact-part(approx,1)) <= part(approx,2)) then foo : 0 else foo : 1,
887 if (foo = 1) then print ("n =", n, " m = ", m, " x = ",x),
888 gomer : cons(foo,gomer)),
889 check_zero_list(gomer));
897 test_name : "simple spherical_bessel_j test",
900 foo : ratsimp(spherical_bessel_j(5,x)),
901 q : makelist(ev(foo / bfloat(spherical_bessel_j(5,0.1 * k)) - 1.0b0,
902 x = 0.1b0 * k),k,1,10),
903 q : map(lambda([s], if abs(s) < 5.0b-11 then 0 else 1), q),
907 (foo : ratsimp(spherical_bessel_j(5,x)),
908 q : makelist(ev(foo / bfloat(spherical_bessel_j(5,0.1 * k)) - 1.0b0,
909 x = 0.1b0 * k),k,-10,-1),
910 q : map(lambda([s], if abs(s) < 5.0b-11 then 0 else 1), q),
914 (test_name : "simple spherical_bessel_y test",
917 foo : expand(spherical_bessel_y(5,x)),
918 q : makelist(ev(foo / bfloat(spherical_bessel_y(5,0.1 * k)) - 1.0b0,
919 x = 0.1b0*k),k,1,10),
920 q : map(lambda([s], if abs(s) < 5.0b-11 then 0 else 1), q),
925 foo : spherical_bessel_y(5,x),
926 q : makelist(ev(foo / bfloat(spherical_bessel_y(5,0.1 * k)) - 1.0b0,
927 x = 0.1b0*k),k,-10,-1),
928 q : map(lambda([s], if abs(s) < 5.0b-11 then 0 else 1), q),
948 (test_name : "A&S 8.5.3",
950 foo(n) := (n + 1)*legendre_q(n+1,x) - (2*n+1)*x*legendre_q(n,x)
951 + n*legendre_q(n-1,x),
952 gomer : makelist(rat(foo(i)),i,1,15),
953 check_zero_list(gomer));
956 (test_name : "A&S 8.5.3",
957 foo(n) := (n + 1)*legendre_p(n+1,x) - (2*n+1)*x*legendre_p(n,x)
958 + n*legendre_p(n-1,x),
959 gomer : makelist(rat(foo(i)),i,1,15),
960 check_zero_list(gomer));
963 (test_name : "A&S 8.5.3",
965 foo(n,m) := (n - m + 1) * assoc_legendre_q(n+1,m,x) -
966 (2*n + 1) * x * assoc_legendre_q(n,m,x) + (n + m) * assoc_legendre_q(n-1,m,x),
968 gomer : makelist(makelist(foo(n,m),m,-n+1,n-1),n,1,5),
969 gomer : map(ratsimp,apply(append, gomer)),
970 check_zero_list(gomer));
975 /* See A&S 8.6.7 page 334
978 (test_name : "A&S 8.6.7",
979 foo : makelist(makelist(assoc_legendre_q(n,m,x) - (-1)^m * (1-x^2)^(m/2) * diff(legendre_q(n,x),x,m),m,0,n),n,0,4),
980 foo : apply(append,foo),
982 check_zero_list(foo));
986 /* See G&R 8.810 page 1014
989 (test_name : "G&R 8.810",
990 foo : makelist(makelist(assoc_legendre_p(n,m,x) - (-1)^m * (1-x^2)^(m/2) * diff(legendre_p(n,x),x,m),n,0,5),m,0,5),
991 foo : apply(append,foo),
993 check_zero_list(foo));
997 /* See G&R 8.813 page 1015
1000 (test_name : "G&R 8.813 (1-6)",
1002 foo : [assoc_legendre_p(1,1,x) + sqrt(1-x^2),
1003 assoc_legendre_p(2,1,x) + 3 * x * sqrt(1-x^2),
1004 assoc_legendre_p(2,2,x) - 3 *(1-x^2),
1005 assoc_legendre_p(3,1,x) + 3 * sqrt(1-x^2) *(5*x^2-1) / 2,
1006 assoc_legendre_p(3,2,x) - 15*x*(1-x^2),
1007 assoc_legendre_p(3,3,x) + 15 * (1-x^2)^(3/2)],
1011 check_zero_list(foo));
1014 /* See G&R 8.950 (1) page 1033
1017 (test_name : "G&R 8.950 (1)",
1018 foo : makelist(hermite(n,x) - (-1)^n * exp(x^2) * diff(exp(-x^2),x,n),n,0,9),
1020 check_zero_list(foo));
1024 /* See G&R 8.952 (1) page 1033
1027 (test_name : "G&R 8.952 (1)",
1028 foo : makelist(diff(hermite(n,x),x) - 2 * n * hermite(n-1,x),n,1,7),
1030 check_zero_list(foo));
1033 /* See G&R 8.952 (2) page 1033
1035 (test_name : "G&R 8.952 (2)",
1036 foo : makelist(hermite(n+1,x) - 2 * x * hermite(n,x) + 2 * n * hermite(n-1,x),n,1,7),
1038 check_zero_list(foo));
1041 /* See G&R 8.956 (1-3) page 1034
1044 (test_name : "G&R 8.956 (1-5)",
1046 foo : [hermite(0,x) - 1,
1048 hermite(2,x) - (4*x^2 -2),
1049 hermite(3,x) - (8*x^3-12*x),
1050 hermite(4,x) - (16*x^4 - 48 * x^2 + 12)],
1052 check_zero_list(foo));
1055 /* See A&S 10.1.19 page 439
1058 (test_name : "A&S 10.1.19 spherical_hankel2",
1059 baz(n) := spherical_hankel2(n-1,x) + spherical_hankel2(n+1,x) - (2*n+1) * spherical_hankel2(n,x) /x,
1060 foo : makelist(baz(k),k,-7,7),
1061 foo : rat(expand(foo)),
1062 check_zero_list(foo));
1065 (test_name : "A&S 10.1.19 spherical_hankel1",
1066 baz(n) := spherical_hankel1(n-1,x) + spherical_hankel1(n+1,x) - (2*n+1) * spherical_hankel1(n,x) /x,
1067 foo : makelist(baz(k),k,-7,7),
1068 foo : rat(expand(foo)),
1069 check_zero_list(foo));
1072 (test_name : "A&S 10.1.19 spherical_bessel_j",
1073 baz(n) := spherical_bessel_j(n-1,x) + spherical_bessel_j(n+1,x) - (2*n+1) * spherical_bessel_j(n,x) /x,
1074 foo : makelist(baz(k),k,-7,7),
1076 check_zero_list(foo));
1079 (test_name : "A&S 10.1.19 spherical_bessel_y",
1080 baz(n) := spherical_bessel_y(n-1,x) + spherical_bessel_y(n+1,x) - (2*n+1) * spherical_bessel_y(n,x) /x,
1081 foo : makelist(baz(k),k,-7,7),
1083 check_zero_list(foo));
1088 /* See A&S 10.1.20 page 439
1091 (test_name : "A&S 10.1.20 spherical_hankel1",
1093 baz(n) := n * spherical_hankel1(n-1,q) - (n+1)*spherical_hankel1(n+1,q)
1094 -(2*n+1) * diff(spherical_hankel1(n,q),q),
1095 foo : makelist(baz(k),k,-7,7),
1097 check_zero_list(foo));
1100 (test_name : "A&S 10.1.20 spherical_hankel2",
1101 baz(n) := n * spherical_hankel2(n-1,q) - (n+1)*spherical_hankel2(n+1,q)
1102 -(2*n+1) * diff(spherical_hankel2(n,q),q),
1103 foo : makelist(baz(k),k,-7,7),
1105 check_zero_list(foo));
1108 (test_name : "A&S 10.1.20 spherical_bessel_j",
1109 baz(n) := n * spherical_bessel_j(n-1,q) - (n+1)*spherical_bessel_j(n+1,q)
1110 -(2*n+1) * diff(spherical_bessel_j(n,q),q),
1111 foo : makelist(baz(k),k,-7,7),
1113 check_zero_list(foo));
1116 (test_name : "A&S 10.1.20 spherical_bessel_y",
1117 baz(n) := n * spherical_bessel_y(n-1,q) - (n+1)*spherical_bessel_y(n+1,q)
1118 -(2*n+1) * diff(spherical_bessel_y(n,q),q),
1119 foo : makelist(baz(k),k,-7,7),
1121 check_zero_list(foo));
1126 (test_name : "A&S 10.1.31",
1127 f(n) := spherical_bessel_j(n,t) *spherical_bessel_y(n-1,t) -
1128 spherical_bessel_j(n-1,t) *spherical_bessel_y(n,t) - 1/t^2,
1130 foo : makelist(f(k),k,-3, 3),
1131 foo : trigreduce(ratsimp(foo)),
1132 check_zero_list(foo));
1140 remvalue(a,b,x,n,m,i,j),
1144 (test_name : "jacobi_p gradef test",
1146 for i : 0 thru 15 do (
1147 foo : diff(jacobi_p(n,a,b,x^2) - jacobi_p(i,a,b,x^2),x),
1151 check_zero_list(q));
1156 (test_name : "ultraspherical gradef test",
1158 for i : 0 thru 15 do (
1159 foo : diff(ultraspherical(n,a,x^2) - ultraspherical(i,a,x^2),x),
1160 foo : ev(foo, n = i),
1163 check_zero_list(q));
1168 (test_name : "assoc_legendre_p gradef test",
1169 remvalue(q,i,j,n,m,x,foo),
1171 for i : 0 thru 15 do (
1172 for j : -15 thru 15 do (
1173 foo : diff(assoc_legendre_p(n,m,x) - assoc_legendre_p(i,j,x),x),
1174 foo : ev(foo, n=i,m=j),
1177 check_zero_list(q));
1182 (test_name : "assoc_legendre_q gradef test",
1183 remvalue(q,i,j,n,m,x,foo,w),
1185 for i : 0 thru 5 do (
1186 for j : -i thru i do (
1187 w : assoc_legendre_q(i,j,x),
1189 foo : diff(assoc_legendre_q(n, m, x),x) - w,
1190 foo : ev(foo, n=i,m=j),
1191 foo : ratsimp(expand(foo)),
1193 check_zero_list(q));
1198 (test_name : "chebyshev_t gradef test",
1200 for i : 0 thru 15 do (
1201 foo : diff(chebyshev_t(n,x^2) - chebyshev_t(i,x^2),x),
1202 foo : ev(foo, n = i),
1205 check_zero_list(q));
1210 (test_name : "chebyshev_u gradef test",
1212 for i : 0 thru 15 do (
1213 foo : diff(chebyshev_u(n,x^2) - chebyshev_u(i,x^2),x),
1217 check_zero_list(q));
1222 (test_name : "laguerre gradef test",
1224 for i : 0 thru 15 do (
1225 foo : diff(laguerre(n,x^2) - laguerre(i,x^2),x),
1229 check_zero_list(q));
1234 (test_name : "gen_laguerre gradef test",
1236 for i : 0 thru 15 do (
1237 foo : diff(gen_laguerre(n,a,x^2) - gen_laguerre(i,a,x^2),x),
1241 check_zero_list(q));
1246 (test_name : "legendre_p gradef test",
1248 for i : 0 thru 15 do (
1249 foo : diff(legendre_p(n,x^2) - legendre_p(i,x^2),x),
1253 check_zero_list(q));
1258 (test_name : "legendre_q gradef test",
1260 for i : 0 thru 15 do (
1261 foo : diff(legendre_q(n,x) - legendre_q(i,x),x),
1265 check_zero_list(q));
1269 (test_name : "hermite gradef test",
1271 for i : 0 thru 15 do (
1272 foo : diff(hermite(n,x^2) - hermite(i,x^2),x),
1276 check_zero_list(q));
1281 (test_name : "spherical_hankel2 gradef test",
1283 for i : 0 thru 15 do (
1284 foo : diff(spherical_hankel2(n,x^2) - spherical_hankel2(i,x^2),x),
1288 check_zero_list(q));
1293 (test_name : "spherical_hankel1 gradef test",
1295 for i : 0 thru 15 do (
1296 foo : diff(spherical_hankel1(n,x^2) - spherical_hankel1(i,x^2),x),
1300 check_zero_list(q));
1305 (test_name : "spherical_bessel_j gradef test",
1307 for i : 0 thru 15 do (
1308 foo : diff(spherical_bessel_j(n,x^2) - spherical_bessel_j(i,x^2),x),
1312 check_zero_list(q));
1317 (test_name : "spherical_bessel_y gradef test",
1319 for i : 0 thru 15 do (
1320 foo : diff(spherical_bessel_y(n,x^2) - spherical_bessel_y(i,x^2),x),
1324 check_zero_list(q));
1330 (test_name : "spherical_harmonic gradef test",
1331 remvalue(q,i,j,n,m,x,foo),
1333 for i : 0 thru 5 do (
1334 for j : -i thru i do (
1335 foo : [diff(spherical_harmonic(n, m, x, y) - spherical_harmonic(i, j, x, y),x),
1336 diff(spherical_harmonic(n, m, x, y) - spherical_harmonic(i,j, x, y),y)],
1337 foo : ev(foo, n=i, m=j),
1339 foo : trigreduce(rat(foo)),
1340 q : append(foo,q))),
1341 check_zero_list(q));
1349 (test_name : "jacobi sum representation",
1351 foo : jacobi_p(n,p,q,2/3),
1352 foo : ev(foo, sum, n=7),
1353 foo : rat(foo - jacobi_p(7,p,q,2/3)),
1354 check_zero_list([foo]));
1359 (test_name : "ultraspherical sum representation",
1360 foo : ultraspherical(n,p,-2/3),
1361 foo : ev(foo, sum, n=2),
1362 foo : rat(foo - ultraspherical(2,p,-2/3)),
1363 check_zero_list([foo]));
1367 (test_name : "legendre_p sum representation",
1368 foo : legendre_p(n,1/8),
1369 foo : ev(foo, sum, n=8),
1370 foo : rat(foo - legendre_p(8,1/8)),
1371 check_zero_list([foo]));
1374 /*----------------*/
1376 (test_name : "chebyshev_t sum representation",
1377 foo : chebyshev_t(n,2),
1378 foo : ev(foo, sum, n=5),
1379 foo : rat(foo - chebyshev_t(5,2)),
1380 check_zero_list([foo]));
1383 /*----------------*/
1385 (test_name : "chebyshev_u sum representation",
1386 foo : chebyshev_u(n,-1/4),
1387 foo : ev(foo, sum, n=15),
1388 foo : rat(foo - chebyshev_u(15,-1/4)),
1389 check_zero_list([foo]));
1394 (test_name : "laguerre sum representation",
1395 foo : laguerre(n,2/3),
1396 foo : ev(foo,sum,n=4),
1397 foo : rat(foo - laguerre(4,2/3)),
1398 check_zero_list([foo]));
1403 (test_name : "generalized laguerre sum representation",
1404 foo : gen_laguerre(n,a,-2/3),
1405 foo : ev(foo,sum,n=4),
1406 foo : rat(foo - gen_laguerre(4,a,-2/3)),
1407 check_zero_list([foo]));
1411 (remvalue([x,n,k]), 0);
1414 (test_name : "pochhammer-1",
1415 check_zero_list(ratsimp([pochhammer(x,0) - 1, pochhammer(x,1) - x,
1416 pochhammer(x,2) - x*(x+1), pochhammer(x,5)/pochhammer(x,4) - (x+4)])));
1419 (test_name : "pochhammer-2",
1420 check_zero_list(makelist(ratsimp(pochhammer(x,-k) * pochhammer(1-x,k) - (-1)^k),k,-5,5)));
1423 (test_name : "pochhammer-grad",
1424 foo : pochhammer(x,n),
1426 goober : makelist(diff(ev(foo,n = k),x) - ev(dfoo,n = k),k,-5,5),
1427 check_zero_list(expand(subst([x = 7/2], goober))));
1430 check_zero_list(expand(subst([x = -7/2], goober)));
1433 /*-----------------*/
1435 (test_name : "unit_step",
1436 check_zero_list([unit_step(-2), unit_step(-1/9), unit_step(-1.2),
1437 unit_step(-1.5b-2), unit_step(0), unit_step(0.0), unit_step(0.0b0),
1438 unit_step(2)-1, unit_step(1/9)-1, unit_step(4.5)-1, unit_step(8.23b3)-1,
1439 unit_step(x^2+1)-1,unit_step(exp(x))-1]));
1442 /*----------------*/
1444 (test_name : "kron_delta",
1446 check_zero_list([kron_delta(1,2), kron_delta(1,1)-1, kron_delta(x,rat(x)) - 1,
1447 kron_delta(x,y)-kron_delta(y,x), kron_delta(1.0,1.0)-1]));
1452 /*----------------*/
1454 (test_name : "jacobi_p recursion",
1456 foo : orthopoly_recur(jacobi_p,[m,a,b,x]),
1457 foo : rhs(foo)-lhs(foo),
1458 foo : makelist(ev(foo,m=k),k,1,6),
1460 check_zero_list(foo));
1463 /*-----------------*/
1464 (test_name : "ultraspherical recursion",
1466 foo : orthopoly_recur(ultraspherical,[m,a,x]),
1467 foo : rhs(foo)-lhs(foo),
1468 foo : makelist(ev(foo,m=k),k,1,6),
1470 check_zero_list(foo));
1473 /*-----------------*/
1474 (test_name : "chebyshev_t_recursion",
1476 foo : orthopoly_recur(chebyshev_t,[m,x]),
1477 foo : rhs(foo)-lhs(foo),
1478 foo : makelist(ev(foo,m=k),k,1,6),
1480 check_zero_list(foo));
1483 /*-----------------*/
1484 (test_name : "chebyshev_u recursion",
1486 foo : orthopoly_recur(chebyshev_u,[m,x]),
1487 foo : rhs(foo)-lhs(foo),
1488 foo : makelist(ev(foo,m=k),k,1,6),
1490 check_zero_list(foo));
1493 /*-----------------*/
1494 (test_name : "legendre_p recursion",
1496 foo : orthopoly_recur(legendre_p,[m,x]),
1497 foo : rhs(foo)-lhs(foo),
1498 foo : makelist(ev(foo,m=k),k,1,6),
1500 check_zero_list(foo));
1503 /*-----------------*/
1504 (test_name : "legendre_q recursion",
1505 foo : orthopoly_recur(legendre_q,[m,x]),
1506 foo : rhs(foo)-lhs(foo),
1507 foo : makelist(ev(foo,m=k),k,1,6),
1509 check_zero_list(foo));
1512 /*-----------------*/
1513 (test_name : "assoc_legendre_p recursion",
1514 foo : orthopoly_recur(assoc_legendre_p,[m,1,x]),
1515 foo : rhs(foo)-lhs(foo),
1516 foo : makelist(ev(foo,m=k),k,2,6),
1518 check_zero_list(foo));
1521 /*-----------------*/
1522 (test_name : "assoc_legendre_p recursion",
1523 foo : orthopoly_recur(assoc_legendre_p,[m,2,x]),
1524 foo : rhs(foo)-lhs(foo),
1525 foo : makelist(ev(foo,m=k),k,3,6),
1527 check_zero_list(foo));
1530 /*-----------------*/
1531 (test_name : "assoc_legendre_q recursion",
1532 foo : orthopoly_recur(assoc_legendre_q,[m,1,x]),
1533 foo : rhs(foo)-lhs(foo),
1534 foo : makelist(ev(foo,m=k),k,2,6),
1536 check_zero_list(foo));
1539 /*----------------*/
1541 (test_name : "laguerre recursion",
1543 foo : orthopoly_recur(laguerre,[m,x]),
1544 foo : rhs(foo)-lhs(foo),
1545 foo : makelist(ev(foo,m=k),k,1,6),
1547 check_zero_list(foo));
1550 /*----------------*/
1552 (test_name : "gen_laguerre recursion",
1554 foo : orthopoly_recur(gen_laguerre,[m,a,x]),
1555 foo : rhs(foo)-lhs(foo),
1556 foo : makelist(ev(foo,m=k),k,1,6),
1558 check_zero_list(foo));
1561 /*-----------------*/
1562 (test_name : "hermite recursion",
1564 foo : orthopoly_recur(hermite,[m,x]),
1565 foo : rhs(foo)-lhs(foo),
1566 foo : makelist(ev(foo,m=k),k,1,6),
1568 check_zero_list(foo));
1571 /*----------------*/
1572 (test_name : "spherical_bessel_j recursion",
1573 foo : orthopoly_recur(spherical_bessel_j,[m,x]),
1574 foo : rhs(foo)-lhs(foo),
1575 foo : makelist(ev(foo,m=k),k,1,6),
1577 check_zero_list(foo));
1581 /*---------------------------------------*/
1582 (test_name : "spherical_bessel_j recursion",
1583 foo : orthopoly_recur(spherical_bessel_y,[m,x]),
1584 foo : rhs(foo)-lhs(foo),
1585 foo : makelist(ev(foo,m=k),k,1,6),
1587 check_zero_list(foo));
1590 /*---------------------------------------*/
1591 (test_name : "spherical_hankel1 recursion",
1592 foo : orthopoly_recur(spherical_hankel1,[m,x]),
1593 foo : rhs(foo)-lhs(foo),
1594 foo : makelist(ev(foo,m=k),k,1,6),
1596 check_zero_list(foo));
1599 /*---------------------------------------*/
1600 (test_name : "spherical_hankel2 recursion",
1601 foo : orthopoly_recur(spherical_hankel2,[m,x]),
1602 foo : rhs(foo)-lhs(foo),
1603 foo : makelist(ev(foo,m=k),k,1,6),
1605 check_zero_list(foo));
1608 /*---------------------------------------*/
1610 (test_name : "jacobi_weight",
1611 foo : orthopoly_weight(jacobi_p,[n,2,3,x]),
1612 foo : integrate(jacobi_p(5,2,3,x) * jacobi_p(4,2,3,x) * foo[1],x,foo[2],foo[3]),
1613 check_zero_list([foo]));
1616 /*---------------------------------------*/
1618 (test_name : "ultraspherical_weight",
1619 foo : orthopoly_weight(ultraspherical,[n,2,x]),
1620 foo : integrate(ultraspherical(5,2,x) * ultraspherical(4,2,x)
1621 * foo[1],x,foo[2],foo[3]),
1622 check_zero_list([foo]));
1625 /*---------------------------------------*/
1627 (test_name : "chebyshev_t_weight",
1628 foo : orthopoly_weight(chebyshev_t,[n,x]),
1629 foo : integrate(chebyshev_t(5,x) * chebyshev_t(4,x)
1630 * foo[1],x,foo[2],foo[3]),
1631 check_zero_list([foo]));
1634 /*---------------------------------------*/
1636 (test_name : "chebyshev_u_weight",
1637 foo : orthopoly_weight(chebyshev_u,[n,x]),
1638 foo : integrate(chebyshev_u(5,x) * chebyshev_u(4,x)
1639 * foo[1],x,foo[2],foo[3]),
1640 check_zero_list([foo]));
1643 /*---------------------------------------*/
1645 (test_name : "legendre_p_weight",
1646 foo : orthopoly_weight(legendre_p,[n,x]),
1647 foo : integrate(legendre_p(5,x) * legendre_p(4,x)
1648 * foo[1],x,foo[2],foo[3]),
1649 check_zero_list([foo]));
1652 /*---------------------------------------*/
1654 (test_name : "laguerre_weight",
1655 foo : orthopoly_weight(laguerre,[n,x]),
1656 foo : integrate(laguerre(5,x) * laguerre(4,x)
1657 * foo[1],x,foo[2],foo[3]),
1658 check_zero_list([foo]));
1661 /*---------------------------------------*/
1663 (test_name : "gen_laguerre_weight",
1664 foo : orthopoly_weight(gen_laguerre,[n,1/2,x]),
1665 foo : integrate(gen_laguerre(5,1/2,x) * gen_laguerre(4,1/2,x)
1666 * foo[1],x,foo[2],foo[3]),
1667 check_zero_list([foo]));
1670 /*---------------------------------------*/
1672 (test_name : "hermite_weight",
1673 foo : orthopoly_weight(hermite,[n,x]),
1674 foo : integrate(hermite(5,x) * hermite(4,x)
1675 * foo[1],x,foo[2],foo[3]),
1676 check_zero_list([foo]));
1680 /*---------------------------------------*/
1682 orthopoly_returns_intervals : false;
1685 (test_name : "legendre_p negative degree--symbolic argument",
1686 foo1 : makelist (legendre_p (-k, u), k, 1, 8),
1687 foo2 : makelist (legendre_p (k - 1, u), k, 1, 8),
1688 check_zero_list(foo1 - foo2));
1691 (test_name : "legendre_p negative degree--rational argument",
1692 foo1 : makelist (legendre_p (-k, 11/7), k, 1, 8),
1693 foo2 : makelist (legendre_p (k - 1, 11/7), k, 1, 8),
1694 check_zero_list(foo1 - foo2));
1697 (test_name : "legendre_p negative degree--float argument",
1698 foo1 : makelist (legendre_p (-k, float (17/16)), k, 1, 8),
1699 foo2 : makelist (legendre_p (k - 1, float (17/16)), k, 1, 8),
1700 foo : map (lambda ([a, b], is (a = b)), foo1, foo2),
1701 check_true_list (foo));
1704 /*---------------------------------------*/
1706 (test_name : "assoc_legendre_p negative degree--symbolic argument",
1707 foo1 : makelist (assoc_legendre_p (-k, 1, u), k, 1, 8),
1708 foo2 : makelist (assoc_legendre_p (k - 1, 1, u), k, 1, 8),
1709 check_zero_list(foo1 - foo2));
1712 (test_name : "assoc_legendre_p negative degree--rational argument",
1713 foo1 : makelist (assoc_legendre_p (-k, 1, 11/7), k, 1, 8),
1714 foo2 : makelist (assoc_legendre_p (k - 1, 1, 11/7), k, 1, 8),
1715 check_zero_list(foo1 - foo2));
1718 (test_name : "assoc_legendre_p negative degree--float argument",
1719 foo1 : makelist (assoc_legendre_p (-k, 1, float (17/16)), k, 1, 8),
1720 foo2 : makelist (assoc_legendre_p (k - 1, 1, float (17/16)), k, 1, 8),
1721 foo : map (lambda ([a, b], is (a = b)), foo1, foo2),
1722 check_true_list (foo));
1725 (reset (orthopoly_returns_intervals), 0);
1728 /* verify that makegamma doesn't create undefined gamma(n) for n <= 0 */
1731 makegamma (pochhammer (n, k)));
1732 gamma (n + k) / gamma (n);
1734 makegamma (pochhammer (3, k));
1735 gamma (k + 3) / gamma (3);
1737 makegamma (pochhammer (0, k));
1740 makegamma (pochhammer (-3, k));
1743 /* verify display for various functions */
1745 (kill (x, y, a, b, m, n, f),
1746 printf (false, "~m", pochhammer (x, n)));
1751 printf (false, "~m", define (f (), pochhammer (x, n)));
1756 printf(false,"~m",jacobi_p(n,a,b,x));
1762 printf(false,"~m",define(f(),jacobi_p(n,a,b,x)));
1768 printf(false,"~m",ultraspherical(n,a,x));
1774 printf(false,"~m",define(f(),ultraspherical(n,a,x)));
1780 printf(false,"~m",chebyshev_t(n,x));
1785 printf(false,"~m",define(f(),chebyshev_t(n,x)));
1790 printf(false,"~m",chebyshev_u(n,x));
1795 printf(false,"~m",define(f(),chebyshev_u(n,x)));
1800 printf(false,"~m",legendre_p(n,x));
1805 printf(false,"~m",define(f(),legendre_p(n,x)));
1810 printf(false,"~m",legendre_q(n,x));
1815 printf(false,"~m",define(f(),legendre_q(n,x)));
1820 printf(false,"~m",assoc_legendre_q(n,m,x));
1826 printf(false,"~m",define(f(),assoc_legendre_q(n,m,x)));
1832 printf(false,"~m",assoc_legendre_p(n,m,x));
1838 printf(false,"~m",define(f(),assoc_legendre_p(n,m,x)));
1844 printf(false,"~m",hermite(n,x));
1849 printf(false,"~m",define(f(),hermite(n,x)));
1854 printf(false,"~m",gen_laguerre(n,a,x));
1860 printf(false,"~m",define(f(),gen_laguerre(n,a,x)));
1866 printf(false,"~m",laguerre(n,x));
1871 printf(false,"~m",define(f(),laguerre(n,x)));
1876 printf(false,"~m",spherical_hankel1(n,x));
1882 printf(false,"~m",define(f(),spherical_hankel1(n,x)));
1888 printf(false,"~m",spherical_hankel2(n,x));
1894 printf(false,"~m",define(f(),spherical_hankel2(n,x)));
1900 printf(false,"~m",spherical_bessel_j(n,x));
1905 printf(false,"~m",define(f(),spherical_bessel_j(n,x)));
1910 printf(false,"~m",spherical_bessel_y(n,x));
1915 printf(false,"~m",define(f(),spherical_bessel_y(n,x)));
1920 printf(false,"~m",spherical_harmonic(n,m,x,y));
1926 printf(false,"~m",define(f(),spherical_harmonic(n,m,x,y)));
1932 /* verify TeX output for gen_laguerre */
1934 tex1 (gen_laguerre (n, a, x));
1935 "L_{n}^{\\left(a\\right)}\\left(x\\right)";
1937 /* SF bug #3631: "gen_laguerre returns 0 to a negative exponent"
1938 * to check results, implement recurrence copied from:
1939 * https://en.wikipedia.org/wiki/Laguerre_polynomials#Generalized_Laguerre_polynomials
1944 L[1](a, x) := 1 + a - x,
1945 L[k](a, x) := ((2*k - 1 + a - x)*L[k - 1](a, x) - (k - 1 + a)*L[k - 2](a, x))/k,
1946 check_gen_laguerre (actual, expected) :=
1947 if ratsimp (actual - expected) = 0 then true
1948 else failed_gen_laguerre ('actual = actual, 'expected = expected),
1952 check_gen_laguerre (gen_laguerre (1, -1, x), L[1](-1, x));
1955 check_gen_laguerre (gen_laguerre (2, -2, x), L[2](-2, x));
1958 makelist (check_gen_laguerre (gen_laguerre (1, a, x), L[1](a, x)), a, -2, 1);
1959 [true, true, true, true];
1961 makelist (check_gen_laguerre (gen_laguerre (2, a, x), L[2](a, x)), a, -3, 1);
1962 [true, true, true, true, true];
1964 makelist (check_gen_laguerre (gen_laguerre (3, a, x), L[3](a, x)), a, -4, 1);
1965 [true, true, true, true, true, true];