-;; Calculator for GNU Emacs, part II [calc-frac.el]
+;;; calc-frac.el --- fraction functions for Calc
+
;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc.
-;; Written by Dave Gillespie, daveg@synaptics.com.
-;; This file is part of GNU Emacs.
+;; Author: David Gillespie <daveg@synaptics.com>
+;; Maintainer: Colin Walters <walters@debian.org>
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY. No author or distributor
;; file named COPYING. Among other things, the copyright notice
;; and this notice must be preserved on all copies.
+;;; Commentary:
+;;; Code:
;; This file is autoloaded from calc-ext.el.
(require 'calc-ext)
(defun calc-Need-calc-frac () nil)
-
(defun calc-fdiv (arg)
(interactive "P")
(calc-slow-wrapper
(defun calc-over-notation (fmt)
- (interactive "sFraction separator (:, ::, /, //, :/): ")
+ (interactive
+ (list
+ (completing-read "Fraction separator: " (mapcar (lambda (s)
+ (cons s 0))
+ '(":" "::" "/" "//" ":/"))
+ nil t)))
(calc-wrapper
(if (string-match "\\`\\([^ 0-9][^ 0-9]?\\)[0-9]*\\'" fmt)
(let ((n nil))
fmt (math-match-substring fmt 1)))
(if (eq n 0) (error "Bad denominator"))
(calc-change-mode 'calc-frac-format (list fmt n) t))
- (error "Bad fraction separator format."))))
+ (error "Bad fraction separator format"))))
(defun calc-slash-notation (n)
(interactive "P")
(calc-wrapper
(calc-change-mode 'calc-prefer-frac n nil t)
(message (if calc-prefer-frac
- "Integer division will now generate fractions."
- "Integer division will now generate floating-point results."))))
-
-
-
+ "Integer division will now generate fractions"
+ "Integer division will now generate floating-point results"))))
;;;; Fractions.
(nth 1 b))))
-
-
;;; Convert a real value to fractional form. [T R I; T R F] [Public]
(defun calcFunc-frac (a &optional tol)
(or tol (setq tol 0))
-;; Calculator for GNU Emacs, part II [calc-funcs.el]
+;;; calc-funcs.el --- well-known functions for Calc
+
;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc.
-;; Written by Dave Gillespie, daveg@synaptics.com.
+
+;; Author: David Gillespie <daveg@synaptics.com>
+;; Maintainer: Colin Walters <walters@debian.org>
;; This file is part of GNU Emacs.
;; file named COPYING. Among other things, the copyright notice
;; and this notice must be preserved on all copies.
+;;; Commentary:
+;;; Code:
;; This file is autoloaded from calc-ext.el.
(require 'calc-ext)
;;; Incomplete gamma function.
+(defvar math-current-gamma-value nil)
(defun calcFunc-gammaP (a x)
(if (equal x '(var inf var-inf))
'(float 1 0)
(math-inc-gamma-series a x)
(math-sub (or math-current-gamma-value (calcFunc-gamma a))
(math-inc-gamma-cfrac a x))))))
-(setq math-current-gamma-value nil)
(defun calcFunc-gammaG (a x)
(if (equal x '(var inf var-inf))
;;; Incomplete beta function.
+(defvar math-current-beta-value nil)
(defun calcFunc-betaI (x a b)
(cond ((math-zerop x)
'(float 0 0))
(math-div (math-mul bt
(math-beta-cfrac b a (math-sub 1 x)))
b))))))))
-(setq math-current-beta-value nil)
(defun math-beta-cfrac (a b x)
(let ((qab (math-add a b))
(calcFunc-euler n '(float 5 -1)))
(calcFunc-euler n '(frac 1 2))))))
+(defvar math-bernoulli-b-cache '((frac -174611
+ (bigpos 0 200 291 698 662 857 802))
+ (frac 43867 (bigpos 0 944 170 217 94 109 5))
+ (frac -3617 (bigpos 0 880 842 622 670 10))
+ (frac 1 (bigpos 600 249 724 74))
+ (frac -691 (bigpos 0 368 674 307 1))
+ (frac 1 (bigpos 160 900 47))
+ (frac -1 (bigpos 600 209 1))
+ (frac 1 30240) (frac -1 720)
+ (frac 1 12) 1 ))
+
+(defvar math-bernoulli-B-cache '((frac -174611 330) (frac 43867 798)
+ (frac -3617 510) (frac 7 6) (frac -691 2730)
+ (frac 5 66) (frac -1 30) (frac 1 42)
+ (frac -1 30) (frac 1 6) 1 ))
+
+(defvar math-bernoulli-cache-size 11)
(defun math-bernoulli-coefs (n)
(let* ((coefs (list (calcFunc-bern n)))
(nn (math-trunc n))
;;; A faster method would be to use "tangent numbers", c.f., Concrete
;;; Mathematics pg. 273.
-(setq math-bernoulli-b-cache '( (frac -174611
- (bigpos 0 200 291 698 662 857 802))
- (frac 43867 (bigpos 0 944 170 217 94 109 5))
- (frac -3617 (bigpos 0 880 842 622 670 10))
- (frac 1 (bigpos 600 249 724 74))
- (frac -691 (bigpos 0 368 674 307 1))
- (frac 1 (bigpos 160 900 47))
- (frac -1 (bigpos 600 209 1))
- (frac 1 30240) (frac -1 720)
- (frac 1 12) 1 ))
-
-(setq math-bernoulli-B-cache '( (frac -174611 330) (frac 43867 798)
- (frac -3617 510) (frac 7 6) (frac -691 2730)
- (frac 5 66) (frac -1 30) (frac 1 42)
- (frac -1 30) (frac 1 6) 1 ))
-
-(setq math-bernoulli-cache-size 11)
-
-
;;; Probability distributions.