| 1545 | |
| 1546 | ;; Bessel J tests for negative order |
| 1547 | (rt:deftest bessel-j.neg-order.d.1 |
| 1548 | (let ((b (bessel-j -1d0 2d0)) |
| 1549 | (true -0.5767248077568734d0)) |
| 1550 | (check-accuracy 50.2 b true)) |
| 1551 | nil) |
| 1552 | |
| 1553 | (rt:deftest bessel-j.neg-order.d.2 |
| 1554 | (let ((b (bessel-j -1d0 1.5d0)) |
| 1555 | (true -0.5579365079100996d0)) |
| 1556 | (check-accuracy 50.5 b true)) |
| 1557 | nil) |
| 1558 | |
| 1559 | (rt:deftest bessel-j.neg-order.d.3 |
| 1560 | (let ((b (bessel-j -1.5d0 2d0)) |
| 1561 | (true -0.3956232813587035d0)) |
| 1562 | (check-accuracy 50.59 b true)) |
| 1563 | nil) |
| 1564 | |
| 1565 | (rt:deftest bessel-j.neg-order.d.4 |
| 1566 | (let ((b (bessel-j -1.8d0 1.5d0)) |
| 1567 | (true -0.251327217627129314d0)) |
| 1568 | (check-accuracy 49.98 b true)) |
| 1569 | nil) |
| 1570 | |
| 1571 | (rt:deftest bessel-j.neg-order.d.5 |
| 1572 | (let ((b (bessel-j -2d0 1.5d0)) |
| 1573 | (true 0.2320876721442147d0)) |
| 1574 | (check-accuracy 51.89 b true)) |
| 1575 | nil) |
| 1576 | |
| 1577 | (rt:deftest bessel-j.neg-order.d.6 |
| 1578 | (let ((b (bessel-j -2.5d0 1.5d0)) |
| 1579 | (true 1.315037204805194d0)) |
| 1580 | (check-accuracy 52.37 b true)) |
| 1581 | nil) |
| 1582 | |
| 1583 | (rt:deftest bessel-j.neg-order.d.7 |
| 1584 | (let ((b (bessel-j -2.3d0 1.5d0)) |
| 1585 | (true 1.012178926325313d0)) |
| 1586 | (check-accuracy 50.01 b true)) |
| 1587 | nil) |
| 1588 | |
| 1589 | ;; Bessel-J tests for positive order |
| 1590 | (rt:deftest bessel-j.pos-order.d.1 |
| 1591 | (let ((b (bessel-j 1.5d0 1d0)) |
| 1592 | (true 0.2402978391234270d0)) |
| 1593 | (check-accuracy 51.83 b true)) |
| 1594 | nil) |
| 1595 | |
| 1596 | (rt:deftest bessel-j.pos-order.d.2 |
| 1597 | (let ((b (bessel-j 1.8d0 1d0)) |
| 1598 | (true 0.1564953153109239d0)) |
| 1599 | (check-accuracy 51.97 b true)) |
| 1600 | nil) |
| 1601 | |
| 1602 | (rt:deftest bessel-j.pos-order.d.3 |
| 1603 | (let ((b (bessel-j 2d0 1d0)) |
| 1604 | (true 0.1149034849319005d0)) |
| 1605 | (check-accuracy 51.87 b true)) |
| 1606 | nil) |
| 1607 | |
| 1608 | (rt:deftest bessel-j.pos-order.d.4 |
| 1609 | (let ((b (bessel-j 2.5d0 1d0)) |
| 1610 | (true 0.04949681022847794d0)) |
| 1611 | (check-accuracy 47.17 b true)) |
| 1612 | nil) |
| 1613 | |
| 1614 | (rt:deftest bessel-j.pos-order.d.5 |
| 1615 | (let ((b (bessel-j -2d0 1.5d0)) |
| 1616 | (true 0.2320876721442147d0)) |
| 1617 | (check-accuracy 51.89 b true)) |
| 1618 | nil) |
| 1619 | |
| 1620 | ;; Bessel J for half integer order and real args |
| 1621 | (rt:deftest bessel-j-1/2.d.1 |
| 1622 | (loop for k from 0 below 100 |
| 1623 | ;; x in [1,1+pi/2] because we don't want to test the Bessel |
| 1624 | ;; series and we don't want to test near pi because sin(pi) |
| 1625 | ;; = 0, where we will lose accuracy. |
| 1626 | for x = (+ 1 (random (/ pi 2))) |
| 1627 | for b = (bessel-j 0.5d0 x) |
| 1628 | for true = (* (/ (sin x) (sqrt x)) (sqrt (/ 2 pi))) |
| 1629 | for result = (check-accuracy 48.42 b true) |
| 1630 | when result |
| 1631 | append (list (list (list k x) result))) |
| 1632 | nil) |
| 1633 | |
| 1634 | (rt:deftest bessel-j-1/2.d.1.a |
| 1635 | (let* ((x 2.3831631289164497d0) |
| 1636 | (b (bessel-j 0.5d0 x)) |
| 1637 | (true (* (/ (sin x) (sqrt x)) (sqrt (/ 2 pi))))) |
| 1638 | (check-accuracy 48.42 b true)) |
| 1639 | nil) |
| 1640 | |
| 1641 | (rt:deftest bessel-j-1/2.q.1 |
| 1642 | (loop for k from 0 below 10 |
| 1643 | ;; x in [1,1+pi/2] because we don't want to test the Bessel |
| 1644 | ;; series and we don't want to test near pi because sin(pi) |
| 1645 | ;; = 0, where we will lose accuracy. |
| 1646 | for x = (+ 1 (random (/ (float-pi #q1) 2))) |
| 1647 | for b = (bessel-j #q0.5 x) |
| 1648 | for true = (* (/ (sin x) (sqrt x)) (sqrt (/ 2 (float-pi #q1)))) |
| 1649 | for result = (check-accuracy 173.28 b true) |
| 1650 | when result |
| 1651 | append (list (list (list k x) result))) |
| 1652 | nil) |
| 1653 | |
| 1654 | (rt:deftest bessel-j-1/2.q.1.a |
| 1655 | (let* ((x #q1.1288834862545916200627583005758663687705443417892789067029865493882q0) |
| 1656 | (b (bessel-j #q0.5 x)) |
| 1657 | (true (* (/ (sin x) (sqrt x)) (sqrt (/ 2 (float-pi #q1)))))) |
| 1658 | (check-accuracy 182.92 b true)) |
| 1659 | nil) |
| 1660 | |
| 1661 | (rt:deftest bessel-j-1/2.q.1.b |
| 1662 | (let* ((x #q1.1288834862545916200627583005758663687705443417892789067029865493882q0) |
| 1663 | (b (bessel-j #q0.5 x)) |
| 1664 | (true (* (/ (sin x) (sqrt x)) (sqrt (/ 2 (float-pi #q1)))))) |
| 1665 | (check-accuracy 173.28 b true)) |
| 1666 | nil) |
| 1667 | |
| 1668 | ;; Bessel J for complex args |
| 1669 | #+nil |
| 1670 | (rt:deftest bessel-j-complex.pos-order.d.1 |
| 1671 | (let ((b (bessel-j 0d0 #c(1d0 1))) |
| 1672 | (true #c(0.9376084768060293d0 -0.4965299476091221d0))) |
| 1673 | (check-accuracy 53 b true)) |
| 1674 | nil) |
| 1675 | |