comparison lisp/calc/calc-funcs.el @ 82442:a2c869327160

(math-besJ0, math-besJ1, math-besY0, math-besY1) (math-bernoulli-b-cache): Remove `eval-when-compile's.
author Jay Belanger <jay.p.belanger@gmail.com>
date Fri, 17 Aug 2007 20:20:03 +0000
parents b98604865ea0
children 107ccd98fa12 aaccdab0ee26
comparison
equal deleted inserted replaced
82441:01eedbaaac05 82442:a2c869327160
567 (math-besJ0 (math-neg x))) 567 (math-besJ0 (math-neg x)))
568 ((Math-lessp '(float 8 0) (math-abs-approx x)) 568 ((Math-lessp '(float 8 0) (math-abs-approx x))
569 (let* ((z (math-div '(float 8 0) x)) 569 (let* ((z (math-div '(float 8 0) x))
570 (y (math-sqr z)) 570 (y (math-sqr z))
571 (xx (math-add x 571 (xx (math-add x
572 (eval-when-compile 572 (math-read-number-simple "-0.785398164")))
573 (math-read-number-simple "-0.785398164"))))
574 (a1 (math-poly-eval y 573 (a1 (math-poly-eval y
575 (eval-when-compile
576 (list 574 (list
577 (math-read-number-simple "0.0000002093887211") 575 (math-read-number-simple "0.0000002093887211")
578 (math-read-number-simple "-0.000002073370639") 576 (math-read-number-simple "-0.000002073370639")
579 (math-read-number-simple "0.00002734510407") 577 (math-read-number-simple "0.00002734510407")
580 (math-read-number-simple "-0.001098628627") 578 (math-read-number-simple "-0.001098628627")
581 '(float 1 0))))) 579 '(float 1 0))))
582 (a2 (math-poly-eval y 580 (a2 (math-poly-eval y
583 (eval-when-compile 581 (list
584 (list 582 (math-read-number-simple "-0.0000000934935152")
585 (math-read-number-simple "-0.0000000934935152") 583 (math-read-number-simple "0.0000007621095161")
586 (math-read-number-simple "0.0000007621095161") 584 (math-read-number-simple "-0.000006911147651")
587 (math-read-number-simple "-0.000006911147651") 585 (math-read-number-simple "0.0001430488765")
588 (math-read-number-simple "0.0001430488765") 586 (math-read-number-simple "-0.01562499995"))))
589 (math-read-number-simple "-0.01562499995")))))
590 (sc (math-sin-cos-raw xx))) 587 (sc (math-sin-cos-raw xx)))
591 (if yflag 588 (if yflag
592 (setq sc (cons (math-neg (cdr sc)) (car sc)))) 589 (setq sc (cons (math-neg (cdr sc)) (car sc))))
593 (math-mul (math-sqrt 590 (math-mul (math-sqrt
594 (math-div (eval-when-compile 591 (math-div (math-read-number-simple "0.636619722")
595 (math-read-number-simple "0.636619722")) 592 x))
596 x))
597 (math-sub (math-mul (cdr sc) a1) 593 (math-sub (math-mul (cdr sc) a1)
598 (math-mul (car sc) (math-mul z a2)))))) 594 (math-mul (car sc) (math-mul z a2))))))
599 (t 595 (t
600 (let ((y (math-sqr x))) 596 (let ((y (math-sqr x)))
601 (math-div (math-poly-eval y 597 (math-div (math-poly-eval y
602 (eval-when-compile 598 (list
603 (list 599 (math-read-number-simple "-184.9052456")
604 (math-read-number-simple "-184.9052456") 600 (math-read-number-simple "77392.33017")
605 (math-read-number-simple "77392.33017") 601 (math-read-number-simple "-11214424.18")
606 (math-read-number-simple "-11214424.18") 602 (math-read-number-simple "651619640.7")
607 (math-read-number-simple "651619640.7") 603 (math-read-number-simple "-13362590354.0")
608 (math-read-number-simple "-13362590354.0") 604 (math-read-number-simple "57568490574.0")))
609 (math-read-number-simple "57568490574.0"))))
610 (math-poly-eval y 605 (math-poly-eval y
611 (eval-when-compile 606 (list
612 (list 607 '(float 1 0)
613 '(float 1 0) 608 (math-read-number-simple "267.8532712")
614 (math-read-number-simple "267.8532712") 609 (math-read-number-simple "59272.64853")
615 (math-read-number-simple "59272.64853") 610 (math-read-number-simple "9494680.718")
616 (math-read-number-simple "9494680.718") 611 (math-read-number-simple "1029532985.0")
617 (math-read-number-simple "1029532985.0") 612 (math-read-number-simple "57568490411.0"))))))))
618 (math-read-number-simple "57568490411.0")))))))))
619 613
620 (defun math-besJ1 (x &optional yflag) 614 (defun math-besJ1 (x &optional yflag)
621 (cond ((and (math-negp (calcFunc-re x)) (not yflag)) 615 (cond ((and (math-negp (calcFunc-re x)) (not yflag))
622 (math-neg (math-besJ1 (math-neg x)))) 616 (math-neg (math-besJ1 (math-neg x))))
623 ((Math-lessp '(float 8 0) (math-abs-approx x)) 617 ((Math-lessp '(float 8 0) (math-abs-approx x))
624 (let* ((z (math-div '(float 8 0) x)) 618 (let* ((z (math-div '(float 8 0) x))
625 (y (math-sqr z)) 619 (y (math-sqr z))
626 (xx (math-add x (eval-when-compile 620 (xx (math-add x (math-read-number-simple "-2.356194491")))
627 (math-read-number-simple "-2.356194491"))))
628 (a1 (math-poly-eval y 621 (a1 (math-poly-eval y
629 (eval-when-compile 622 (list
630 (list 623 (math-read-number-simple "-0.000000240337019")
631 (math-read-number-simple "-0.000000240337019") 624 (math-read-number-simple "0.000002457520174")
632 (math-read-number-simple "0.000002457520174") 625 (math-read-number-simple "-0.00003516396496")
633 (math-read-number-simple "-0.00003516396496") 626 '(float 183105 -8)
634 '(float 183105 -8) 627 '(float 1 0))))
635 '(float 1 0)))))
636 (a2 (math-poly-eval y 628 (a2 (math-poly-eval y
637 (eval-when-compile 629 (list
638 (list 630 (math-read-number-simple "0.000000105787412")
639 (math-read-number-simple "0.000000105787412") 631 (math-read-number-simple "-0.00000088228987")
640 (math-read-number-simple "-0.00000088228987") 632 (math-read-number-simple "0.000008449199096")
641 (math-read-number-simple "0.000008449199096") 633 (math-read-number-simple "-0.0002002690873")
642 (math-read-number-simple "-0.0002002690873") 634 (math-read-number-simple "0.04687499995"))))
643 (math-read-number-simple "0.04687499995")))))
644 (sc (math-sin-cos-raw xx))) 635 (sc (math-sin-cos-raw xx)))
645 (if yflag 636 (if yflag
646 (setq sc (cons (math-neg (cdr sc)) (car sc))) 637 (setq sc (cons (math-neg (cdr sc)) (car sc)))
647 (if (math-negp x) 638 (if (math-negp x)
648 (setq sc (cons (math-neg (car sc)) (math-neg (cdr sc)))))) 639 (setq sc (cons (math-neg (car sc)) (math-neg (cdr sc))))))
649 (math-mul (math-sqrt (math-div 640 (math-mul (math-sqrt (math-div
650 (eval-when-compile 641 (math-read-number-simple "0.636619722")
651 (math-read-number-simple "0.636619722"))
652 x)) 642 x))
653 (math-sub (math-mul (cdr sc) a1) 643 (math-sub (math-mul (cdr sc) a1)
654 (math-mul (car sc) (math-mul z a2)))))) 644 (math-mul (car sc) (math-mul z a2))))))
655 (t 645 (t
656 (let ((y (math-sqr x))) 646 (let ((y (math-sqr x)))
657 (math-mul 647 (math-mul
658 x 648 x
659 (math-div (math-poly-eval y 649 (math-div (math-poly-eval y
660 (eval-when-compile 650 (list
661 (list 651 (math-read-number-simple "-30.16036606")
662 (math-read-number-simple "-30.16036606") 652 (math-read-number-simple "15704.4826")
663 (math-read-number-simple "15704.4826") 653 (math-read-number-simple "-2972611.439")
664 (math-read-number-simple "-2972611.439") 654 (math-read-number-simple "242396853.1")
665 (math-read-number-simple "242396853.1") 655 (math-read-number-simple "-7895059235.0")
666 (math-read-number-simple "-7895059235.0") 656 (math-read-number-simple "72362614232.0")))
667 (math-read-number-simple "72362614232.0"))))
668 (math-poly-eval y 657 (math-poly-eval y
669 (eval-when-compile 658 (list
670 (list 659 '(float 1 0)
671 '(float 1 0) 660 (math-read-number-simple "376.9991397")
672 (math-read-number-simple "376.9991397") 661 (math-read-number-simple "99447.43394")
673 (math-read-number-simple "99447.43394") 662 (math-read-number-simple "18583304.74")
674 (math-read-number-simple "18583304.74") 663 (math-read-number-simple "2300535178.0")
675 (math-read-number-simple "2300535178.0") 664 (math-read-number-simple "144725228442.0")))))))))
676 (math-read-number-simple "144725228442.0"))))))))))
677 665
678 (defun calcFunc-besY (v x) 666 (defun calcFunc-besY (v x)
679 (math-inexact-result) 667 (math-inexact-result)
680 (or (math-numberp v) (math-reject-arg v 'numberp)) 668 (or (math-numberp v) (math-reject-arg v 'numberp))
681 (or (math-numberp x) (math-reject-arg x 'numberp)) 669 (or (math-numberp x) (math-reject-arg x 'numberp))
710 by)))))) 698 by))))))
711 699
712 (defun math-besY0 (x) 700 (defun math-besY0 (x)
713 (cond ((Math-lessp (math-abs-approx x) '(float 8 0)) 701 (cond ((Math-lessp (math-abs-approx x) '(float 8 0))
714 (let ((y (math-sqr x))) 702 (let ((y (math-sqr x)))
715 (math-add 703 (math-add
716 (math-div (math-poly-eval y 704 (math-div (math-poly-eval y
717 (eval-when-compile 705 (list
718 (list 706 (math-read-number-simple "228.4622733")
719 (math-read-number-simple "228.4622733") 707 (math-read-number-simple "-86327.92757")
720 (math-read-number-simple "-86327.92757") 708 (math-read-number-simple "10879881.29")
721 (math-read-number-simple "10879881.29") 709 (math-read-number-simple "-512359803.6")
722 (math-read-number-simple "-512359803.6") 710 (math-read-number-simple "7062834065.0")
723 (math-read-number-simple "7062834065.0") 711 (math-read-number-simple "-2957821389.0")))
724 (math-read-number-simple "-2957821389.0"))))
725 (math-poly-eval y 712 (math-poly-eval y
726 (eval-when-compile 713 (list
727 (list 714 '(float 1 0)
728 '(float 1 0) 715 (math-read-number-simple "226.1030244")
729 (math-read-number-simple "226.1030244") 716 (math-read-number-simple "47447.2647")
730 (math-read-number-simple "47447.2647") 717 (math-read-number-simple "7189466.438")
731 (math-read-number-simple "7189466.438") 718 (math-read-number-simple "745249964.8")
732 (math-read-number-simple "745249964.8") 719 (math-read-number-simple "40076544269.0"))))
733 (math-read-number-simple "40076544269.0"))))) 720 (math-mul (math-read-number-simple "0.636619772")
734 (math-mul (eval-when-compile
735 (math-read-number-simple "0.636619772"))
736 (math-mul (math-besJ0 x) (math-ln-raw x)))))) 721 (math-mul (math-besJ0 x) (math-ln-raw x))))))
737 ((math-negp (calcFunc-re x)) 722 ((math-negp (calcFunc-re x))
738 (math-add (math-besJ0 (math-neg x) t) 723 (math-add (math-besJ0 (math-neg x) t)
739 (math-mul '(cplx 0 2) 724 (math-mul '(cplx 0 2)
740 (math-besJ0 (math-neg x))))) 725 (math-besJ0 (math-neg x)))))
746 (let ((y (math-sqr x))) 731 (let ((y (math-sqr x)))
747 (math-add 732 (math-add
748 (math-mul 733 (math-mul
749 x 734 x
750 (math-div (math-poly-eval y 735 (math-div (math-poly-eval y
751 (eval-when-compile 736 (list
752 (list 737 (math-read-number-simple "8511.937935")
753 (math-read-number-simple "8511.937935") 738 (math-read-number-simple "-4237922.726")
754 (math-read-number-simple "-4237922.726") 739 (math-read-number-simple "734926455.1")
755 (math-read-number-simple "734926455.1") 740 (math-read-number-simple "-51534381390.0")
756 (math-read-number-simple "-51534381390.0") 741 (math-read-number-simple "1275274390000.0")
757 (math-read-number-simple "1275274390000.0") 742 (math-read-number-simple "-4900604943000.0")))
758 (math-read-number-simple "-4900604943000.0"))))
759 (math-poly-eval y 743 (math-poly-eval y
760 (eval-when-compile 744 (list
761 (list 745 '(float 1 0)
762 '(float 1 0) 746 (math-read-number-simple "354.9632885")
763 (math-read-number-simple "354.9632885") 747 (math-read-number-simple "102042.605")
764 (math-read-number-simple "102042.605") 748 (math-read-number-simple "22459040.02")
765 (math-read-number-simple "22459040.02") 749 (math-read-number-simple "3733650367.0")
766 (math-read-number-simple "3733650367.0") 750 (math-read-number-simple "424441966400.0")
767 (math-read-number-simple "424441966400.0") 751 (math-read-number-simple "24995805700000.0")))))
768 (math-read-number-simple "24995805700000.0")))))) 752 (math-mul (math-read-number-simple "0.636619772")
769 (math-mul (eval-when-compile (math-read-number-simple "0.636619772"))
770 (math-sub (math-mul (math-besJ1 x) (math-ln-raw x)) 753 (math-sub (math-mul (math-besJ1 x) (math-ln-raw x))
771 (math-div 1 x)))))) 754 (math-div 1 x))))))
772 ((math-negp (calcFunc-re x)) 755 ((math-negp (calcFunc-re x))
773 (math-neg 756 (math-neg
774 (math-add (math-besJ1 (math-neg x) t) 757 (math-add (math-besJ1 (math-neg x) t)
830 (progn 813 (progn
831 (math-inexact-result) 814 (math-inexact-result)
832 (calcFunc-euler n '(float 5 -1))) 815 (calcFunc-euler n '(float 5 -1)))
833 (calcFunc-euler n '(frac 1 2)))))) 816 (calcFunc-euler n '(frac 1 2))))))
834 817
835 (defvar math-bernoulli-b-cache 818 (defvar math-bernoulli-b-cache
836 (eval-when-compile 819 (list
837 (list 820 (list 'frac
838 (list 'frac 821 -174611
839 -174611 822 (math-read-number-simple "802857662698291200000"))
840 (math-read-number-simple "802857662698291200000")) 823 (list 'frac
841 (list 'frac 824 43867
842 43867 825 (math-read-number-simple "5109094217170944000"))
843 (math-read-number-simple "5109094217170944000")) 826 (list 'frac
844 (list 'frac 827 -3617
845 -3617 828 (math-read-number-simple "10670622842880000"))
846 (math-read-number-simple "10670622842880000")) 829 (list 'frac
847 (list 'frac 830 1
848 1 831 (math-read-number-simple "74724249600"))
849 (math-read-number-simple "74724249600")) 832 (list 'frac
850 (list 'frac 833 -691
851 -691 834 (math-read-number-simple "1307674368000"))
852 (math-read-number-simple "1307674368000")) 835 (list 'frac
853 (list 'frac 836 1
854 1 837 (math-read-number-simple "47900160"))
855 (math-read-number-simple "47900160")) 838 (list 'frac
856 (list 'frac 839 -1
857 -1 840 (math-read-number-simple "1209600"))
858 (math-read-number-simple "1209600")) 841 (list 'frac
859 (list 'frac 842 1
860 1 843 30240)
861 30240) 844 (list 'frac
862 (list 'frac 845 -1
863 -1 846 720)
864 720) 847 (list 'frac
865 (list 'frac 848 1
866 1 849 12)
867 12) 850 1 ))
868 1 ))) 851
869 852 (defvar math-bernoulli-B-cache
870 (defvar math-bernoulli-B-cache '((frac -174611 330) (frac 43867 798) 853 '((frac -174611 330) (frac 43867 798)
871 (frac -3617 510) (frac 7 6) (frac -691 2730) 854 (frac -3617 510) (frac 7 6) (frac -691 2730)
872 (frac 5 66) (frac -1 30) (frac 1 42) 855 (frac 5 66) (frac -1 30) (frac 1 42)
873 (frac -1 30) (frac 1 6) 1 )) 856 (frac -1 30) (frac 1 6) 1 ))
874 857
875 (defvar math-bernoulli-cache-size 11) 858 (defvar math-bernoulli-cache-size 11)
876 (defun math-bernoulli-coefs (n) 859 (defun math-bernoulli-coefs (n)
877 (let* ((coefs (list (calcFunc-bern n))) 860 (let* ((coefs (list (calcFunc-bern n)))
878 (nn (math-trunc n)) 861 (nn (math-trunc n))