1 ;;;; -*- Mode: Lisp; Package: Maxima; Syntax: Common-Lisp; Base: 10 -*- ;;;;
3 ;;;; This file contains global vars (defvars/defmvars) that are used in
4 ;;;; multiple files. We gather them all here so that they are
5 ;;;; consistently defined across the build and to make the dependencies
10 (defvar *variable-initial-values
* (make-hash-table)
11 "Hash table containing all Maxima defmvar variables and their
14 (defmacro defmvar
(var &optional val doc
&rest options
)
15 "Define a Maxima variable VAR that is user-visible. It is
16 initialized to the value VAL. An associated documentation string
17 can be supplied in DOC. OPTIONS contains a list of options that can
18 be applied to the variable.
20 The valid options are:
23 - If given, the variable will not be reset.
24 FIXNUM, BOOLEAN, STRING, FLONUM
25 - The type of variable. Currently ignored.
27 - A list of properties to be applied for this variable. It is
28 a list of lists. Each sublist is a list of the property and
29 the value to be assigned to the property.
31 - A function of one argument that returns NIL if the given
32 value is not a valid value for the variable.
34 - A list of values that can be assigned to the variable. An
35 error is signaled if an attempt to assign a different value
38 - The variable is marked as deprecated. The option is a
39 string to be printed when this deprecated variable is used.
40 A warning is printed once when first used. This option
41 overrides any other options. When the variable is used, a
42 message is printed of the form: \"Deprecated variable
43 `<var>': <string>\" where <var> is the name of this
44 variable, and <string> is the value given to :deprecated-p.
48 (defmvar $foo foo-value
49 \"Docstring for deprecated foo.\"
50 :deprecated-p \"Use bar instead\")
52 The list of properties has the form ((ind1 val1) (ind2 val2) ...)
53 where IND1 is the name of the property and VAL1 is the value
54 associated with the property.
56 Other options that are recognized but ignored: IN-CORE, SEE-ALSO,
57 MODIFIED-COMMANDS. For any other options, a warning is produced.
59 Do not use both :SETTING-PREDICATE and :SETTING-LIST. Also do not
60 use a :PROPERTIES with an 'ASSIGN property. :SETTING-PREDICATE and
61 :SETTING-LIST sets the 'ASSIGN property to implement the
67 ;; Default is to reset the variable to it's initial value.
68 `((unless (gethash ',var
*variable-initial-values
*)
69 (setf (gethash ',var
*variable-initial-values
*)
79 (do ((opts options
(rest opts
)))
82 (format t
"opts = ~S~%" opts
)
86 ;; Don't reset the value
87 (setf maybe-reset nil
)))
88 ((fixnum boolean string flonum
)
89 ;; Don't declare the types yet. There are testsuite failures
90 ;; with sbcl that some things declared fixnum aren't assigned
91 ;; fixnum values. Some are clearly bugs in the code where we
97 ;; Some known such variables: $expop, $fpprintprec (in ev
98 ;; statements), $factors_only, $expon,
100 ;; We should also note that when this is fixed, we should
101 ;; also add an 'assign property to verify that only fixnums,
102 ;; etc., are allowed.
104 (setf maybe-declare-type
105 `((declaim (type ,(car opts
) ,var
)))))
111 (setf maybe-set-props
112 (mapcar #'(lambda (o)
113 (destructuring-bind (ind val
)
115 (when (eql ind
'assign
)
116 (setf assign-property-p t
))
117 `(putprop ',var
,val
',ind
)))
119 (when assign-property-p
120 (when setting-predicate-p
121 (error "Cannot use 'ASSIGN property in :PROPERTIES if :SETTING-PREDICATE already specified."))
123 (error "Cannot use 'ASSIGN property in :PROPERTIES if :SETTING-LIST already specified."))))
124 (setf opts
(rest opts
)))
128 (error "Cannot use :SETTING-PREDICATE when :SETTING-LIST already specified."))
129 (when assign-property-p
130 (error "Cannot use :SETTING-PREDICATE when :PROPERTIES uses the 'ASSIGN property."))
131 (setf setting-predicate-p t
)
132 ;; A :SETTING-PREDICATE is a function (symbol or lambda) of
133 ;; one arg specifying the value that variable is to be set
134 ;; to. It should return non-NIL if the value is valid. An
135 ;; optional second value may be returned. This is a string
136 ;; that can be used as the reason arg for MSETERR to explain
137 ;; why the setting failed.
139 ;; WARNING: Do not also have a :properties item with an
140 ;; 'assign property. Currently this takes precedence.
143 (multiple-value-bind (ok reason
)
144 (funcall ,(second opts
) val
)
146 (mseterr var val reason
))))))
147 (setf maybe-predicate
148 `((putprop ',var
,assign-func
'assign
)))))
150 ;; Skip over the predicate function.
151 (setf opts
(rest opts
)))
154 (when setting-predicate-p
155 (error "Cannot use :SETTING-LIST when :SETTING-PREDICATE already specified."))
156 (when assign-property-p
157 (error "Cannot use :SETTING-LIST when :PROPERTIES uses the 'ASSIGN property."))
158 (setf setting-list-p t
)
159 ;; A :SETTING-LIST is a list of possible values that can be
160 ;; assigned to the variable. An error is signaled if the
161 ;; variable is not assigned to one of these values. This
162 ;; could be handled with :SETTING-PREDICATE, of course. This
163 ;; is a convenience feature but it also makes it explicit
164 ;; that we only allow the possible values.
167 (let ((possible-values ',(second opts
)))
168 (unless (member val possible-values
)
170 (let ((*print-case
* :downcase
))
171 (format nil
"must be one of: ~{~A~^, ~}"
172 (mapcar #'stripdollar possible-values
)))))))))
173 (setf maybe-predicate
174 `((putprop ',var
,assign-func
'assign
)))))
175 ;; Skip over the values.
176 (setf opts
(rest opts
)))
177 ((see-also modified-commands setting-list
)
178 ;; Not yet supported, but we need to skip over the following
179 ;; item too which is the parameter for this option.
180 (setf opts
(rest opts
)))
182 ;; This overrides everything and makes the variable
183 ;; deprecated. This means it's unbound, and the 'bindtest
184 ;; property is set and the 'assign property is set to
185 ;; 'neverset. The option is a string for the bindtest
189 maybe-declare-type nil
191 setting-predicate-p nil
193 assign-property-p nil
)
194 (setf maybe-set-props
195 `((cl:makunbound
',var
)
196 (putprop ',var
:deprecated
'bindtest
)
197 (putprop ',var
'neverset
'assign
)
198 (setf *bindtest-deprecation-messages
*
202 "Deprecated variable `~M': "
205 *bindtest-deprecation-messages
*))))
206 (setf opts
(rest opts
)))
208 (warn "Ignoring unknown defmvar option for ~S: ~S"
213 (defvar ,var
,val
,doc
)
217 ;; For the symbol SYM, add to the plist the property INDIC with a
220 ;; Some known INDIC properties
223 ;; When a variable is assigned (in maxima), the 'assign property
224 ;; is used to check whether the value to be assigned is valid.
225 ;; The value can be anything that can be funcall'ed. If it
226 ;; returns, then the assignment proceeds. Thus, if the value is
227 ;; invalid, an error must be signaled.
229 ;; When a symbol <x> has this property, expressions 'ev(<expr>,
230 ;; <x>)' and '<expr>, <x>' are equivalent to 'ev(<expr>,
231 ;; <x>=true)'. See the user manual for more details.
233 ;; When true, it denotes that the symbol is a constant and
234 ;; cannot be changed by the user. This includes things like
235 ;; $%pi, $%e, $inf, $minf, $true, and $false.
236 (defun putprop (sym val indic
)
238 (setf (getf (cdr sym
) indic
) val
)
239 (setf (get sym indic
) val
)))
241 ;;------------------------------------------------------------------------
244 ;; Declare user-visible special variables and other global special variables.
246 ;; Should these be defconstants? I (rtoy) don't think they should be
247 ;; allowed to be changed.
248 (defmvar *infinities
* '($inf $minf $infinity
)
249 "The types of infinities recognized by Maxima.
250 INFINITY is complex infinity")
252 (defmvar *real-infinities
* '($inf $minf
)
253 "The real infinities, `inf' is positive infinity, `minf' negative infinity")
255 (defmvar *infinitesimals
* '($zeroa $zerob
)
256 "The infinitesimals recognized by Maxima. ZEROA zero from above,
257 ZEROB zero from below")
259 ;;------------------------------------------------------------------------
262 ;; Define useful floating-point constants
265 ;; This used to be enabled, but
266 ;; http://clisp.cons.org/impnotes/num-dict.html seems to indicate
267 ;; that the result of float, coerce, sqrt, etc., on a rational will
268 ;; return a float of the specified type. But ANSI CL says we must
269 ;; return a single-float. I (rtoy) am commenting this out for now.
271 ;; (setq custom:*default-float-format* 'double-float)
273 ;; We currently don't want any warnings about floating-point contagion.
274 (setq custom
::*warn-on-floating-point-contagion
* nil
)
276 ;; We definitely want ANSI-style floating-point contagion.
277 (setq custom
:*floating-point-contagion-ansi
* t
)
279 ;; Set custom:*floating-point-rational-contagion-ansi* so that
280 ;; contagion is done as per the ANSI CL standard. Has an effect only
281 ;; in those few cases when the mathematical result is exact although
282 ;; one of the arguments is a floating-point number, such as (* 0
283 ;; 1.618), (/ 0 1.618), (atan 0 1.0), (expt 2.0 0)
284 (setq custom
:*floating-point-rational-contagion-ansi
* t
)
286 ;; When building maxima using with 'flonum being a 'long-float it may be
287 ;; useful to adjust the number of bits of precision that CLISP uses for
290 (setf (ext:long-float-digits
) 128)
292 ;; We want underflows not to signal errors.
293 (ext:without-package-lock
()
294 (setq sys
::*inhibit-floating-point-underflow
* t
))
299 ;; We want underflows not to signal errors
300 (when (fboundp (find-symbol "FLOAT-UNDERFLOW-MODE" "SYS"))
301 (funcall (find-symbol "FLOAT-UNDERFLOW-MODE" "SYS") nil
))
304 ;; Make the maximum exponent larger for CMUCL. Without this, cmucl
305 ;; will generate a continuable error when raising an integer to a
306 ;; power greater than this.
308 (setf ext
::*intexp-maximum-exponent
* 100000)
309 ;;;; Setup the mapping from the Maxima 'flonum float type to a CL float type.
311 ;;;; Add :flonum-long to *features* if you want flonum to be a
312 ;;;; long-float. Or add :flonum-double-double if you want flonum to
313 ;;;; be a double-double (currently only for CMUCL). Otherwise, you
314 ;;;; get double-float as the flonum type.
316 ;;;; Default double-float flonum.
317 (eval-when (:compile-toplevel
:load-toplevel
:execute
)
318 (setq *read-default-float-format
* 'double-float
))
320 #-
(or flonum-long flonum-double-double
)
322 ;; Tell Lisp the float type for a 'flonum.
324 (deftype flonum
(&optional low high
)
326 `(double-float ,low
,high
))
328 `(double-float ,low
))
332 ;; Some versions of clisp and ABCL appear to be buggy: (coerce 1 'flonum)
333 ;; signals an error. So does (coerce 1 '(double-float 0d0)). But
334 ;; (coerce 1 'double-float) returns 1d0 as expected. So for now, make
335 ;; flonum be exactly the same as double-float, without bounds.
337 (deftype flonum
(&optional low high
)
338 (declare (ignorable low high
))
341 (defconstant +most-positive-flonum
+ most-positive-double-float
)
342 (defconstant +most-negative-flonum
+ most-negative-double-float
)
343 (defconstant +least-positive-flonum
+ least-positive-double-float
)
344 (defconstant +least-negative-flonum
+ least-negative-double-float
)
345 (defconstant +flonum-epsilon
+ double-float-epsilon
)
346 (defconstant +least-positive-normalized-flonum
+ least-positive-normalized-double-float
)
347 (defconstant +least-negative-normalized-flonum
+ least-negative-normalized-double-float
)
349 (defconstant +flonum-exponent-marker
+ #\D
)
354 ;;;; The Maxima 'flonum can be a CL 'long-float on the Scieneer CL or CLISP,
355 ;;;; but should be the same as 'double-float on other CL implementations.
357 (eval-when (:compile-toplevel
:load-toplevel
:execute
)
358 (setq *read-default-float-format
* 'long-float
))
360 ;; Tell Lisp the float type for a 'flonum.
361 (deftype flonum
(&optional low high
)
363 `(long-float ,low
,high
))
369 (defconstant +most-positive-flonum
+ most-positive-long-float
)
370 (defconstant +most-negative-flonum
+ most-negative-long-float
)
371 (defconstant +least-positive-flonum
+ least-positive-long-float
)
372 (defconstant +least-negative-flonum
+ least-negative-long-float
)
373 (defconstant +flonum-epsilon
+ long-float-epsilon
)
374 (defconstant +least-positive-normalized-flonum
+ least-positive-normalized-long-float
)
375 (defconstant +least-negative-normalized-flonum
+ least-negative-normalized-long-float
)
377 (defconstant +flonum-exponent-marker
+ #\L
)
381 #+flonum-double-double
384 ;;;; The Maxima 'flonum can be a 'kernel:double-double-float on the CMU CL.
386 (eval-when (:compile-toplevel
:load-toplevel
:execute
)
387 (setq *read-default-float-format
* 'kernel
:double-double-float
))
389 ;; Tell Lisp the float type for a 'flonum.
390 (deftype flonum
(&optional low high
)
392 `(kernel:double-double-float
,low
,high
))
394 `(kernel:double-double-float
,low
))
396 'kernel
:double-double-float
)))
398 ;; While double-double can represent number as up to
399 ;; most-positive-double-float, it can't really do operations on them
400 ;; due to the way multiplication and division are implemented. (I
401 ;; don't think there's any workaround for that.)
403 ;; So, the largest number that can be used is the float just less than
404 ;; 2^1024/(1+2^27). This is the number given here.
405 (defconstant most-positive-double-double-hi
406 (scale-float (cl:float
(1- 9007199187632128) 1d0
) 944))
408 (defconstant +most-positive-flonum
+ (cl:float most-positive-double-double-hi
1w0
))
409 (defconstant +most-negative-flonum
+ (cl:float
(- most-positive-double-double-hi
1w0
)))
410 (defconstant +least-positive-flonum
+ (cl:float least-positive-double-float
1w0
))
411 (defconstant +least-negative-flonum
+ (cl:float least-negative-double-float
1w0
))
412 ;; This is an approximation to a double-double epsilon. Due to the
413 ;; way double-doubles are represented, epsilon is actually zero
414 ;; because 1+x = 1 only when x is zero. But double-doubles only have
415 ;; 106 bits of precision, so we use that as epsilon.
416 (defconstant +flonum-epsilon
+ (scale-float 1w0 -
106))
417 (defconstant +least-positive-normalized-flonum
+ (cl:float least-positive-normalized-double-float
1w0
))
418 (defconstant +least-negative-normalized-flonum
+ (cl:float least-negative-normalized-double-float
1w0
))
420 (defconstant +flonum-exponent-marker
+ #\W
)
424 ;;------------------------------------------------------------------------
426 (defmvar $%rnum_list
'((mlist))
427 "Upon exit from ALGSYS this is bound to a list of the %RNUMS which
428 where introduced into the expression. Useful for mapping over and
429 using as an argument to SUBST.")
430 ;;------------------------------------------------------------------------
433 "When true, 'zeta' returns an expression proportional to '%pi^n' for
438 (defmvar $factlim
100000 ; set to a big integer which will work (not -1)
439 "specifies the highest factorial which is automatically expanded. If
440 it is -1 then all integers are expanded.")
443 (defmvar $cauchysum nil
444 "When multiplying together sums with INF as their upper limit, causes
445 the Cauchy product to be used rather than the usual product. In the
446 Cauchy product the index of the inner summation is a function of the
447 index of the outer one rather than varying independently."
448 modified-commands
'$sum
449 :properties
((evflag t
)))
452 (defmvar $gensumnum
0
453 "The numeric suffix used to generate the next variable of summation.
454 If it is set to FALSE then the index will consist only of GENINDEX
455 with no numeric suffix."
456 modified-commands
'$sum
457 :setting-predicate
#'(lambda (x)
461 "must be false or a non-negative integer")))
463 (defmvar $genindex
'$i
464 "The alphabetic prefix used to generate the next variable of summation
466 modified-commands
'$sum
467 :setting-predicate
#'symbolp
)
470 "when false, 'bern' excludes the Bernoulli numbers and 'euler'
471 excludes the Euler numbers which are equal to zero.")
472 (defmvar $simpsum nil
473 "When true, the result of a 'sum' is simplified. This simplification
474 may sometimes be able to produce a closed form."
475 :properties
((evflag t
)))
476 (defmvar $simpproduct nil
477 "When true, the result of a 'product' is simplified. This
478 simplification may sometimes be able to produce a closed form."
479 :properties
((evflag t
)))
481 (defvar *infsumsimp t
)
484 "Controls the number of terms of the continued fraction the function
485 'cf' will give, as the value 'cflength' times the period.")
486 (defmvar $taylordepth
3
487 "If there are still no nonzero terms, 'taylor' doubles the degree of
488 the expansion of '<g>(<x>)' so long as the degree of the expansion
489 is less than or equal to '<n> 2^taylordepth'.")
490 (defmvar $verbose nil
491 "When true, 'powerseries' prints progress messages.")
493 (defvar silent-taylor-flag nil
494 ;; From comment in hayat.lisp
495 "If true indicates that errors will be returned via a throw to
498 ;; linear operator stuff
499 (defparameter *opers-list
'(($linear . linearize1
)))
501 (defparameter opers
(list '$linear
))
503 ;;------------------------------------------------------------------------
505 (defmvar $rootsconmode t
506 "Governs the behavior of the 'rootscontract' command. See
507 'rootscontract' for details.")
509 ;;------------------------------------------------------------------------
511 (defmvar $exptsubst nil
512 "When 'true', permits substitutions such as 'y' for '%e^x' in
514 (defmvar $partswitch nil
515 "When true, 'end' is returned when a selected part of an expression
516 doesn't exist, otherwise an error message is given.")
518 "When true, functions for part extraction inspect the internal form of
520 (defmvar $derivsubst nil
521 "When true, a non-syntactic substitution such as 'subst (x, 'diff (y,
522 t), 'diff (y, t, 2))' yields ''diff (x, t)'.")
524 "When false, 'subst' does not attempt to substitute into the operator
528 "When T, sdiff is called from the function islinear")
530 "When T, prevents substitution from applying to vars ; bound by %sum,
531 %product, %integrate, %limit")
533 ;; Store built-in operators, which get additional properties.
534 ;; These operators aren't killed by the function kill-operator.
537 (defvar atvars
'($
@1 $
@2 $
@3 $
@4))
541 (defvar dummy-variable-operators
'(%product %sum %laplace %integrate %limit %at
))
543 ;;------------------------------------------------------------------------
545 (defvar $context
'$global
546 "Whenever a user assumes a new fact, it is placed in the context named
547 as the current value of the variable CONTEXT. Similarly, FORGET
548 references the current value of CONTEXT. To add or DELETE a fact
549 from a different context, one must bind CONTEXT to the intended
550 context and then perform the desired additions or deletions. The
551 context specified by the value of CONTEXT is automatically
552 activated. All of MACSYMA's built-in relational knowledge is
553 contained in the default context GLOBAL.")
555 (defmvar $contexts
'((mlist) $global
)
556 "A list of the currently active contexts."
558 :properties
((assign 'neverset
)))
560 (defvar $activecontexts
'((mlist))
561 "A list of the currently activated contexts")
563 (defvar *complexsign
* nil
564 "If T, COMPAR works in a complex mode.")
566 (defmvar $prederror nil
567 "When true, an error message is displayed whenever the predicate of an
568 'if' statement or an 'is' function fails to evaluate to either
572 (defmvar sign-imag-errp t
573 "If T errors out in case COMPAR meets up with an imaginary
574 quantity. If NIL THROWs in that case."
577 ;;------------------------------------------------------------------------
579 (defmvar $polyfactor nil
580 "When T factor the polynomial over the real or complex numbers.")
582 ;;------------------------------------------------------------------------
584 (defmvar $gamma_expand nil
585 "Expand gamma(z+n) for n an integer when T.")
587 ;;------------------------------------------------------------------------
589 (defmvar $demoivre nil
590 "When true, complex exponentials are converted into equivalent
591 expressions in terms of circular functions."
592 :properties
((evflag t
)))
593 (defmvar $nointegrate nil
)
594 (defmvar $lhospitallim
4
595 "The maximum number of times L'Hospital's rule is used in 'limit'.")
596 (defmvar $tlimswitch t
597 "When true, the 'limit' command will use a Taylor series expansion if
598 the limit of the input expression cannot be computed directly.")
599 (defmvar $limsubst nil
600 "When false, prevents 'limit' from attempting substitutions on unknown
606 ;; Simplified shortcuts of constant expressions involving %pi.
607 (defvar %p%i
'((mtimes) $%i $%pi
)
609 (defvar fourth%pi
'((mtimes) ((rat simp
) 1 4) $%pi
)
611 (defvar half%pi
'((mtimes) ((rat simp
) 1 2) $%pi
)
613 (defvar %pi2
'((mtimes) 2 $%pi
)
615 (defvar half%pi3
'((mtimes) ((rat simp
) 3 2) $%pi
)
618 (defmvar $sumsplitfact t
619 "When false, 'minfactorial' is applied after a 'factcomb'.")
621 ;;------------------------------------------------------------------------
623 (defmvar integerl nil
624 "An integer-list for non-atoms found out to be `integer's")
626 (defmvar nonintegerl nil
627 "A non-integer-list for non-atoms found out to be `noninteger's")
629 ;; Not really sure what this is meant to do, but it's used by MTORAT,
630 ;; KEYHOLE, and POLELIST.
631 (defvar *semirat
* nil
)
633 ;;------------------------------------------------------------------------
636 "When true, output expressions are not displayed.")
638 (defmvar $display2d t
639 "Causes equations to be drawn in two dimensions. Otherwise, drawn
642 (defmvar $lispdisp nil
643 "Causes symbols not having $ as the first character in their pnames to
644 be preceded with a ? when displayed.")
646 (defmvar $derivabbrev nil
647 "When true, symbolic derivatives (that is, 'diff' nouns) are displayed
648 as subscripts. Otherwise, derivatives are displayed in the Leibniz
651 (defmvar $stringdisp nil
652 "Causes strings to be bracketed in double quotes when displayed.
653 Normally this is off, but is turned on when a procedure definition
654 is being displayed.")
656 ;; These three variables are bound within Macsyma Listeners since they are different
657 ;; for each window. Set them here, anyway, so that RETRIEVE can be called from
658 ;; top level. The size of TOP-WINDOW is wired in here.
661 "The assumed width (in characters) of the console display for the
662 purpose of displaying expressions."
663 :setting-predicate
#'(lambda (val)
664 ;; The value must be fixnum within range.
665 ;; The upper limit was arbitrarily chosen.
666 (values (and (fixnump val
)
668 "must be an integer between 0 and 1000001, exclusive")))
669 (defvar ttyheight
24.
)
671 (defmvar $known_index_properties
'((mlist) $presubscript $presuperscript $postsubscript $postsuperscript
))
673 (defvar *display-labels-p
* t
)
675 ;;------------------------------------------------------------------------
677 (defmvar $packagefile nil
678 "When true, prevent information from being added to Maxima's
679 information-lists (e.g. 'values', 'functions') except where
680 necessary when the file is loaded in. Useful for package designers
681 who use 'save' or 'translate' to create packages (files).")
683 ;;------------------------------------------------------------------------
686 "If TRUE, no MAXIMA-ERROR message is printed when a floating point
687 number is converted to a bigfloat number.")
689 (defmvar $bftorat nil
690 "Controls the conversion of bigfloat numbers to rational numbers. If
691 FALSE, RATEPSILON will be used to control the conversion (this
692 results in relatively small rational numbers). If TRUE, the
693 rational number generated will accurately represent the bigfloat.")
696 "If TRUE, printing of bigfloat numbers will truncate trailing zeroes.
697 Otherwise, all trailing zeroes are printed.")
699 (defmvar $fpprintprec
0
700 "Controls the number of significant digits printed for floats. If
701 0, then full precision is used."
703 :setting-predicate
#'(lambda (val)
704 ;; $fpprintprec must be a non-negative fixnum
705 ;; and also cannot be equal to 1.
706 (values (and (fixnump val
)
709 "must be a non-negative integer and not equal to -1")))
711 (defmvar $maxfpprintprec
(ceiling (log (expt 2 (float-digits 1.0)) 10.0))
712 "The maximum number of significant digits printed for floats.")
714 (defmvar $fpprec $maxfpprintprec
715 "Number of decimal digits of precision to use when creating new
716 bigfloats. One extra decimal digit in actual representation for
718 :properties
((assign 'fpprec1
)))
720 (defmvar bigfloatzero
'((bigfloat simp
56.
) 0 0)
721 "Bigfloat representation of 0"
724 (defmvar bigfloatone
'((bigfloat simp
56.
) #.
(expt 2 55.
) 1)
725 "Bigfloat representation of 1"
728 (defmvar bfhalf
'((bigfloat simp
56.
) #.
(expt 2 55.
) 0)
729 "Bigfloat representation of 1/2")
731 (defmvar bfmhalf
'((bigfloat simp
56.
) #.
(- (expt 2 55.
)) 0)
732 "Bigfloat representation of -1/2")
734 (defmvar bigfloat%e
'((bigfloat simp
56.
) 48968212118944587.
2)
735 "Bigfloat representation of %E")
737 (defmvar bigfloat%pi
'((bigfloat simp
56.
) 56593902016227522.
2)
738 "Bigfloat representation of %pi")
740 (defmvar bigfloat%gamma
'((bigfloat simp
56.
) 41592772053807304.
0)
741 "Bigfloat representation of %gamma")
743 (defmvar bigfloat_log2
'((bigfloat simp
56.
) 49946518145322874.
0)
744 "Bigfloat representation of log(2)")
746 ;; Number of bits of precision in the mantissa of newly created bigfloats.
747 ;; FPPREC = ($FPPREC+1)*(Log base 2 of 10)
751 ;;------------------------------------------------------------------------
753 (defmvar $factorial_expand nil
754 "Controls the simplification of expressions like '(n+1)!', where 'n'
755 is an integer. See 'factorial'.")
756 (defmvar $beta_expand nil
757 "When true, 'beta(a,b)' and related functions are expanded for
758 arguments like a+n or a-n, where n is an integer.")
760 (defmvar $hypergeometric_representation nil
761 "When T a transformation to a hypergeometric representation is done.")
763 ;;------------------------------------------------------------------------
765 (defmvar $listconstvars nil
766 "Causes LISTOFVARS to include %E, %PI, %I, and any variables declared
767 constant in the list it returns if they appear in exp. The default
768 is to omit these." boolean see-also $listofvars
)
770 ;;------------------------------------------------------------------------
772 (defmvar $showtime nil
773 "When T, the computation time is printed with each output expression.")
776 "last thing read in, corresponds to lisp +")
778 "thing read in which will be evaluated, corresponds to -")
780 ;;------------------------------------------------------------------------
782 (defmvar $globalsolve nil
783 "When true, solved-for variables are assigned the solution values
784 found by 'linsolve', and by 'solve' when solving two or more linear
787 "When true and if 'ratmx' is 'true', then 'determinant' will use
788 special routines for computing sparse determinants.")
789 (defmvar $backsubst t
790 "When false, prevents back substitution in 'linsolve' after the
791 equations have been triangularized.")
794 "The counter for the '%r' variables introduced in solutions by 'solve'
797 (defmvar $linsolve_params t
798 "When true, 'linsolve' also generates the '%r' symbols used to
799 represent arbitrary parameters described in the manual under
805 ;;------------------------------------------------------------------------
808 "When true, the determinant of a matrix whose inverse is computed is
809 factored out of the inverse.")
811 "When 'ratmx' is 'false', determinant and matrix addition,
812 subtraction, and multiplication are performed in the representation
813 of the matrix elements and cause the result of matrix inversion to
814 be left in general representation.
816 When 'ratmx' is 'true', the 4 operations mentioned above are
817 performed in CRE form and the result of matrix inverse is in CRE
819 :properties
((evflag t
)))
820 (defmvar $matrix_element_mult
"*"
821 "The operation invoked in place of multiplication in a matrix
822 multiplication. 'matrix_element_mult' can be assigned any binary
824 (defmvar $matrix_element_add
"+"
825 "the operation invoked in place of addition in a matrix
826 multiplication. 'matrix_element_add' can be assigned any n-ary
829 ;;------------------------------------------------------------------------
831 (defmvar $dotscrules nil
832 "Causes a non-commutative product of a scalar and another term to be
833 simplified to a commutative product. Scalars and constants are
834 carried to the front of the expression."
835 :properties
((evflag t
)))
837 (defmvar $dotdistrib nil
838 "Causes every non-commutative product to be expanded each time it is
839 simplified, i.e. A . (B + C) will simplify to A . B + A . C.")
841 (defmvar $dotexptsimp t
"Causes A . A to be simplified to A ^^ 2.")
844 "Causes a non-commutative product to be considered associative, so
845 that A . (B . C) is simplified to A . B . C. If this flag is off,
846 dot is taken to be right associative, i.e. A . B . C is simplified
848 :properties
((assign #'(lambda (name val
)
849 (declare (ignore name
))
850 (cput 'mnctimes val
'associative
)))))
852 (defmvar $doallmxops t
853 "Causes all operations relating to matrices (and lists) to be carried
854 out. For example, the product of two matrices will actually be
855 computed rather than simply being returned. Turning on this switch
856 effectively turns on the following three.")
858 (defmvar $domxmxops t
"Causes matrix-matrix operations to be carried out.")
860 (defmvar $doscmxops nil
"Causes scalar-matrix operations to be carried out.")
862 (defmvar $scalarmatrixp t
863 "Causes a square matrix of dimension one to be converted to a scalar,
864 i.e. its only element.")
866 (defmvar $assumescalar t
867 "This governs whether unknown expressions 'exp' are assumed to
868 behave like scalars for combinations of the form 'exp op matrix'
869 where op is one of {+, *, ^, .}. It has three settings:
871 FALSE -- such expressions behave like non-scalars.
872 TRUE -- such expressions behave like scalars only for the commutative
873 operators but not for non-commutative multiplication.
874 ALL -- such expressions will behave like scalars for all operators
877 Note: This switch is primarily for the benefit of old code. If
878 possible, you should declare your variables to be SCALAR or
879 NONSCALAR so that there is no need to rely on the setting of this
882 ;;------------------------------------------------------------------------
884 (defmvar $error
`((mlist simp
) "No error.")
885 "During an MAXIMA-ERROR break this is bound to a list of the
886 arguments to the call to MAXIMA-ERROR, with the message text in a
888 :properties
((assign 'neverset
)))
890 (defmvar $errormsg
't
891 "If `false' then no maxima-error message is printed!")
893 ;;------------------------------------------------------------------------
896 '($integer $noninteger $even $odd $rational $irrational $real $imaginary $complex
897 $analytic $increasing $decreasing $oddfun $evenfun $posfun $constant
898 $commutative $lassociative $rassociative $symmetric $antisymmetric
901 (defmvar $features
(cons '(mlist simp
) (append featurel nil
))
902 "A list of mathematical features which are mathematical preoperties of
903 functions and variables.")
904 (defmvar $%enumer nil
905 "When true, '%e' is replaced by its numeric value 2.718... whenever
907 :properties
((evflag t
)))
909 "Causes non-integral rational numbers and bigfloat numbers to be
910 converted to floating point."
911 :properties
((evflag t
)))
912 (defmvar $translate nil
913 "Causes automatic translation of a user's function to Lisp.")
915 "When false, the interpreted version of all functions to be
916 run (provided they are still around) rather than the translated
919 "When true, the Maxima version of a user function is preserved when
920 the function is translated. This permits the definition to be
921 displayed by 'dispfun' and allows the function to be edited.")
922 (defmvar $infeval nil
923 "When true, Enables \"infinite evaluation\" mode. 'ev' repeatedly
924 evaluates an expression until it stops changing."
925 :properties
((evflag t
)))
926 (defmvar $piece
'$piece
927 "Holds the last expression selected when using the 'part' functions.")
929 ;; These three variables are what get stuck in array slots as magic
930 ;; unbound objects. They are for T, FIXNUM, and FLONUM type arrays
933 (defvar munbound
'|
#####|
)
934 (defvar fixunbound most-negative-fixnum
)
935 (defvar flounbound
+most-negative-flonum
+)
937 (defmvar munbindp nil
938 "Used for safely `munbind'ing incorrectly-bound variables."
941 (defmvar $setcheck nil
942 "If 'setcheck' is set to a list of variables (which can be
943 subscripted), Maxima prints a message whenever the variables, or
944 subscripted occurrences of them, are bound with the ordinary
945 assignment operator ':', the '::' assignment operator, or function
946 argument binding, but not the function assignment ':=' nor the macro
947 assignment '::=' operators. The message comprises the name of the
948 variable and the value it is bound to.
950 'setcheck' may be set to 'all' or 'true' thereby including all
952 :setting-predicate
#'(lambda (val)
953 (values (or ($listp val
)
954 (member val
'($all t nil
)))
955 "must be a list or one of all, true, or false")))
958 ;;Function Call stack each element is
959 ;; (fname . bindlist) where bindlist was the value at time of entry.
960 ;; So you can use this to compute what the bindings were at any
962 (defvar *mlambda-call-stack
* (make-array 30 :fill-pointer
0 :adjustable t
))
964 ;; If this is T then arrays are stored in the value cell,
965 ;; whereas if it is false they are stored in the function cell
966 (defmvar $use_fast_arrays nil
967 "When true, arrays declared by 'array' are values instead of
968 properties, and undeclared arrays ('hashed arrays') are implemented
969 as Lisp hashed arrays.")
971 (defvar bindlist nil
)
974 (defvar scanmapp nil
)
982 (defvar factlist nil
)
983 (defvar *nounsflag
* nil
)
985 (defvar noevalargs nil
)
987 (defmvar $structures
'((mlist))
990 :properties
((assign 'neverset
)))
992 (defvar mspeclist nil
)
994 ;;------------------------------------------------------------------------
996 (defmvar $load_pathname nil
997 "The full pathname of the file being loaded")
999 (defvar *maxima-testsdir
*)
1001 ;;------------------------------------------------------------------------
1003 (defmvar $powerdisp nil
1004 "When true, a sum is displayed with its terms in order of increasing
1006 (defmvar $pfeformat nil
1007 "When true, a ratio of integers is displayed with the solidus (forward
1008 slash) character, and an integer denominator 'n' is displayed as a
1009 leading multiplicative term '1/n'.")
1010 (defmvar $%edispflag nil
1011 "When true, Maxima displays '%e' to a negative exponent as a
1013 (defmvar $sqrtdispflag t
1014 "When false, causes 'sqrt' to display with exponent 1/2.")
1016 ;;------------------------------------------------------------------------
1018 (defmvar $ratwtlvl nil
1019 "'ratwtlvl' is used in combination with the 'ratweight' function to
1020 control the truncation of canonical rational expressions (CRE). For
1021 the default value of 'false', no truncation occurs."
1022 :properties
((assign #'(lambda (name val
)
1023 ;; Forward declaration
1024 (declare (special $ratfac
))
1025 (when (and val
(not (fixnump val
)))
1026 (mseterr name val
"must be an integer"))
1027 (when (and val $ratfac
)
1028 (merror (intl:gettext
"assignment: 'ratfac' and 'ratwtlvl' may not both be used at the same time.")))))))
1030 (defmvar $ratalgdenom t
;If T then denominator is rationalized.
1031 "When true, allows rationalization of denominators with respect to
1032 radicals to take effect."
1033 :properties
((evflag t
)))
1035 ;;------------------------------------------------------------------------
1037 ;; List of GCD algorithms. Default one is first.
1038 (defmvar *gcdl
* '($spmod $subres $ez $red $mod $algebraic
))
1040 (defmvar $gcd
(car *gcdl
*) ;Sparse Modular
1041 "The default GCD algorithm. If false, the GCD is prevented from being
1042 taken when expressions are converted to canonical rational
1043 expression (CRE) form."
1044 :setting-predicate
#'(lambda (val)
1046 (member val
*gcdl
*))))
1049 ;; It is convenient to have the *bigprimes* be actually less than half
1050 ;; the size of the most positive fixnum, so that arithmetic is easier.
1052 ;; *bigprimes* and *alpha are initialized in
1053 ;; initialize-runtime-globals instead of here because *bigprimes*
1054 ;; needs the NEXT-PRIME function to generate the list of primes, and
1055 ;; NEXT-PRIME isn't available yet. Likewise, *alpha is initialized to
1056 ;; the first element of *bigprimes*.
1057 (defvar *bigprimes
*)
1060 ;;------------------------------------------------------------------------
1062 (defmvar algfac
* nil
)
1064 (defmvar $intfaclim t
1065 "If 'true', maxima will give up factorization of integers if no factor
1066 is found after trial divisions and Pollard's rho method and
1067 factorization will not be complete.
1069 When 'intfaclim' is 'false' (this is the case when the user calls
1070 'factor' explicitly), complete factorization will be attempted.")
1071 (defmvar $factor_max_degree
1000
1072 "If set to an integer n, some potentially large (many factors)
1073 polynomials of degree > n won't be factored, preventing huge memory
1074 allocations and stack overflows. Set to zero to deactivate."
1076 :properties
((assign 'posintegerset
)))
1078 (defmvar $savefactors nil
"If t factors of ratreped forms will be saved")
1080 (defvar *checkfactors
* () "List of saved factors")
1082 ;;------------------------------------------------------------------------
1085 ;; User level global variables.
1086 (defmvar $keepfloat nil
1087 "If `t' floating point coeffs are not converted to rationals"
1088 :properties
((evflag t
)))
1089 (defmvar $factorflag nil
1090 "If `t' constant factor of polynomial is also factored"
1091 :properties
((evflag t
)))
1092 (defmvar $dontfactor
'((mlist))
1093 "A list of variables with respect to which factoring is not to occur.")
1094 (defmvar $norepeat t
)
1095 (defmvar $ratweights
'((mlist simp
))
1096 "The list of weights assigned by 'ratweight'."
1097 :properties
((assign
1098 #'(lambda (name val
)
1099 (cond ((not ($listp val
))
1100 (mseterr name val
"must be a list"))
1102 (kill1 '$ratweights
))
1104 (apply #'$ratweight
(cdr val
))))))))
1106 (defmvar $algebraic nil
1107 "Set to 'true' in order for the simplification of algebraic integers
1109 :properties
((evflag t
)))
1111 (defmvar $ratfac nil
1112 "If `t' cre-forms are kept factored"
1113 :properties
((evflag t
)
1114 (assign #'(lambda (name val
)
1115 (declare (ignore name
))
1116 (when (and val $ratwtlvl
)
1117 (merror (intl:gettext
"assignment: 'ratfac' and 'ratwtlvl' may not both be used at the same time.")))))))
1119 (defmvar $ratvars
'((mlist simp
))
1120 "A list of the arguments of the function 'ratvars' when it was called
1121 most recently. Each call to the function 'ratvars' resets the
1123 :properties
((assign #'(lambda (name val
)
1125 (apply #'$ratvars
(cdr val
))
1126 (mseterr name val
"must be a list"))))))
1128 (defmvar $facexpand t
1129 "Controls whether the irreducible factors returned by 'factor' are in
1130 expanded (the default) or recursive (normal CRE) form.")
1133 "List of gensyms used to point to kernels from within polynomials.
1134 The values cell and property lists of these symbols are used to
1135 store various information.")
1137 (defmvar genpairs nil
)
1139 (defmvar *fnewvarsw nil
)
1140 (defmvar *ratweights nil
)
1142 (defmvar tellratlist nil
)
1145 "common denom for algebraic coefficients")
1147 ;; Any program which calls RATF on
1148 ;; a floating point number but does not wish to see "RAT replaced ..."
1149 ;; message, must bind $RATPRINT to NIL.
1151 (defmvar $ratprint t
1152 "When true, a message informing the user of the conversion of floating
1153 point numbers to rational numbers is displayed.")
1155 (defmvar $ratepsilon
2d-15
1156 "The tolerance used in the conversion of floating point numbers to
1157 rational numbers, when the option variable 'bftorat' has the value
1160 ;; IF $RATEXPAND IS TRUE, (X+1)*(Y+1) WILL DISPLAY AS
1161 ;; XY + Y + X + 1 OTHERWISE, AS (X+1)Y + X + 1
1162 (defmvar $ratexpand nil
1163 "Controls some simplifications of radicals. See user manual for
1164 complicated rules.")
1166 (defmvar varlist nil
1169 ;;------------------------------------------------------------------------
1171 (defmvar $resultant
'$subres
1172 "Designates which resultant algorithm")
1174 ;;------------------------------------------------------------------------
1177 "Controls whether `risch' generates polylogs")
1179 ;;------------------------------------------------------------------------
1181 ;; General purpose simplification and conversion switches.
1183 (defmvar $negdistrib t
1184 "Causes negations to be distributed over sums, e.g. -(A+B) is
1185 simplified to -A-B.")
1188 "Causes SOME mathematical functions (including exponentiation) with
1189 numerical arguments to be evaluated in floating point. It causes
1190 variables in an expression which have been given NUMERVALs to be
1191 replaced by their values. It also turns on the FLOAT switch."
1192 see-also
($numerval $float
)
1193 :properties
((assign 'numerset
)))
1196 "Enables simplification."
1197 :properties
((evflag t
)))
1199 (defmvar $sumexpand nil
1200 "If TRUE, products of sums and exponentiated sums go into nested
1202 :properties
((evflag t
)))
1204 (defmvar $numer_pbranch nil
1205 "When true and the exponent is a floating point number or the option
1206 variable 'numer' is 'true' too, Maxima evaluates the numerical
1207 result using the principal branch. Otherwise a simplified, but not
1208 an evaluated result is returned."
1209 :properties
((evflag t
)))
1211 ;; Switches dealing with expansion.
1213 "The largest positive exponent which will be automatically
1214 expanded. (X+1)^3 will be automatically expanded if EXPOP is
1215 greater than or equal to 3."
1217 see-also
($expon $maxposex $expand
))
1220 "The largest negative exponent which will be automatically
1221 expanded. (X+1)^(-3) will be automatically expanded if EXPON is
1222 greater than or equal to 3."
1224 see-also
($expop $maxnegex $expand
))
1226 (defmvar $maxposex
1000.
1227 "The largest positive exponent which will be expanded by the EXPAND
1230 see-also
($maxnegex $expop $expand
)
1231 ;; Check assignment to be a positive integer
1232 :properties
((assign 'posintegerset
)))
1234 (defmvar $maxnegex
1000.
1235 "The largest negative exponent which will be expanded by the EXPAND
1238 see-also
($maxposex $expon $expand
)
1239 ;; Check assignment to be a positive integer
1240 :properties
((assign 'posintegerset
)))
1242 ;; Lisp level variables
1244 "Causes SIMP flags to be ignored. $EXPAND works by binding $EXPOP to
1245 $MAXPOSEX, $EXPON to $MAXNEGEX, and DOSIMP to T.")
1248 (defmvar errorsw nil
1249 "Causes a throw to the tag ERRORSW when certain errors occur rather
1250 than the printing of a message. Kludgy MAXIMA-SUBSTITUTE for
1251 MAXIMA-ERROR signalling.")
1253 (defmvar $rootsepsilon
1d-7
1254 "The tolerance which establishes the confidence interval for the
1255 roots found by the 'realroots' function.")
1256 (defmvar $algepsilon
100000000)
1258 (defmvar $false nil
)
1259 (defmvar $logabs nil
1260 "When true, indefinite integration where logs are generated,
1261 e.g. 'integrate(1/x,x) produces answers in terms of log(...) instead
1263 :properties
((evflag t
)))
1264 (defmvar $listarith t
1265 "If 'false' causes any arithmetic operations with lists to be
1266 suppressed; when 'true', list-matrix operations are contagious
1267 causing lists to be converted to matrices yielding a result which is
1269 :properties
((evflag t
)))
1270 (defmvar $domain
'$real
)
1271 (defmvar $m1pbranch nil
1272 "When true, the principal branch for -1 to a power is returned,
1273 depending on whether 'domain' is real or complex."
1274 :properties
((evflag t
)))
1275 (defmvar $%e_to_numlog nil
1276 "When 'true', 'r' some rational number, and 'x' some
1277 expression,'%e^(r*log(x))' will be simplified into 'x^r'.")
1279 "When '%emode' is 'true', '%e^(%pi %i x)' is simplified. See the user
1280 manual for more details."
1281 :properties
((evflag t
)))
1282 (defmvar $ratsimpexpons nil
1283 "When true, 'ratsimp' is applied to the exponents of expressions
1284 during simplification."
1285 :properties
((evflag t
)))
1286 (defmvar $logexpand t
; Possible values are T, $ALL and $SUPER
1287 "Controls how logs are expanded. See the user manual."
1288 :properties
((evflag t
)))
1289 (defmvar $radexpand t
1290 "Controls some simplification of radicals. See the user manual."
1291 :properties
((evflag t
))
1292 :setting-predicate
#'(lambda (val)
1293 ;; $radexpand can only be set to $all, $true,
1295 (values (member val
'($all t nil
))
1296 "must be one of all, true, or false")))
1297 (defmvar $subnumsimp nil
1298 "When true, the functions 'subst' and 'psubst' can substitute a
1299 subscripted variable 'f[x]' with a number, when only the symbol 'f'
1302 "If 'false' then no simplification of '%e' to a power containing
1306 (defvar rp-polylogp nil
)
1308 (defvar derivflag nil
)
1309 (defvar *zexptsimp? nil
)
1311 ;; This is initialized in initialize-runtime-globals
1313 ;;------------------------------------------------------------------------
1316 "Causes solutions to cubic and quartic equations to be expressed in
1317 terms of common subexpressions.")
1319 (defmvar $multiplicities
'$not_set_yet
1320 "Set to a list of the multiplicities of the individual solutions
1321 returned by SOLVE, REALROOTS, or ALLROOTS.")
1323 (defmvar $programmode t
1324 "Causes SOLVE to return its answers explicitly as elements in a list
1325 rather than printing E-labels."
1326 :properties
((evflag t
)))
1328 (defmvar $solvefactors t
1329 "If T, then SOLVE will try to factor the expression. The FALSE
1330 setting may be desired in zl-SOME cases where factoring is not
1333 (defmvar $solvetrigwarn t
1334 "Causes SOLVE to print a warning message when it is uses inverse
1335 trigonometric functions to solve an equation, thereby losing
1338 (defmvar $solveradcan nil
1339 "SOLVE will use RADCAN which will make SOLVE slower but will allow
1340 certain problems containing exponentials and logs to be solved.")
1343 ;;------------------------------------------------------------------------
1345 (defmvar $niceindicespref
'((mlist simp
) $i $j $k $l $m $n
)
1346 "The list from which 'niceindices' takes the names of indices for sums
1348 :properties
((assign #'(lambda (name val
)
1349 ;; The value must be a nonempty list
1350 ;; consisting of symbols. While
1351 ;; niceindices can handle subscripted
1352 ;; variables, sum and product cannot, so
1353 ;; for now we'll restrict the possible
1354 ;; values to be simple symbols.
1355 (unless (and ($listp val
)
1357 (every '$symbolp
(cdr val
)))
1359 (intl:gettext
"~M: value must be a nonempty list of symbols; found: ~:M")
1363 ;;------------------------------------------------------------------------
1365 (defmvar $loadprint nil
1366 "Controls whether to print a message when a file is loaded.")
1367 (defmvar $nolabels nil
1368 "When 'true', input and output result labels ('%i' and '%o',
1369 respectively) are displayed, but the labels are not bound to
1370 results, and the labels are not appended to the 'labels' list.
1371 Since labels are not bound to results, garbage collection can
1372 recover the memory taken up by the results.")
1374 ;; For each of the variables below ($aliases to $dependencies), create
1375 ;; a new list as the initial value instead of '((mlist simp)). Ecl
1376 ;; can and will coalesce these to be the same list, and this causes
1377 ;; problems if one of the variables is destructively modified in
1379 (defmvar $aliases
(list '(mlist simp
))
1380 "The list of atoms which have a user defined alias (set up by the
1381 'alias', 'ordergreat', 'orderless' functions or by declaring the
1382 atom a 'noun' with 'declare'."
1384 :properties
((assign 'neverset
)))
1386 ;; Define $infolist variables here and set up the initial value and
1388 (defmvar $labels
(list '(mlist simp
))
1389 "The list of input, output, and intermediate expression labels,
1390 including all previous labels if 'inchar', 'outchar', or 'linechar'
1392 :properties
((assign 'neverset
)))
1394 (defmvar $values
(list '(mlist simp
))
1395 "The list of all bound user variables (not Maxima options or
1396 switches). The list comprises symbols bound by ':', or '::'."
1398 :properties
((assign 'neverset
)))
1400 (defmvar $functions
(list '(mlist simp
))
1401 "The list of ordinary Maxima functions in the current session. An
1402 ordinary function is a function constructed by 'define' or ':=' and
1403 called with parentheses '()'."
1405 :properties
((assign 'neverset
)))
1407 (defmvar $macros
(list '(mlist simp
))
1408 "The list of user-defined macro functions. The macro function
1409 definition operator '::=' puts a new macro function onto this list."
1411 :properties
((assign 'neverset
)))
1413 (defmvar $arrays
(list '(mlist simp
))
1414 "The list of arrays that have been allocated. These comprise arrays
1415 declared by 'array', 'hashed arrays' that can be constructed by
1416 implicit definition (assigning something to an element that isn't
1417 yet declared as a list or an array), and 'memoizing functions'
1418 defined by ':=' and 'define'. Arrays defined by 'make_array' are
1421 :properties
((assign 'neverset
)))
1424 (defmvar $myoptions
(list '(mlist simp
))
1425 "The list of all options ever reset by the user, whether or not they
1426 get reset to their default value."
1428 :properties
((assign 'neverset
)))
1430 (defmvar $props
(list '(mlist simp
))
1431 "The list of atoms which have any property other than those explicitly
1432 mentioned in 'infolists', such as specified by 'atvalue',
1433 'matchdeclare', etc., as well as properties specified in the
1434 'declare' function."
1436 :properties
((assign 'neverset
)))
1438 (defmvar $rules
(list '(mlist simp
))
1441 :properties
((assign 'neverset
)))
1443 (defmvar $gradefs
(list '(mlist simp
))
1444 "The list of the functions for which partial derivatives have been
1445 defined by 'gradef'."
1447 :properties
((assign 'neverset
)))
1449 (defmvar $dependencies
(list '(mlist simp
))
1450 "The list of atoms which have functional dependencies, assigned by
1451 'depends', the function 'dependencies', or 'gradef'. The
1452 'dependencies' list is cumulative: each call to 'depends',
1453 'dependencies', or 'gradef' appends additional items."
1455 :properties
((assign 'neverset
)))
1457 (defmvar $let_rule_packages
'((mlist) $default_let_rule_package
)
1458 "The names of the various let rule simplification packages"
1459 :properties
((assign 'let-rule-setter
)))
1462 '((mlist simp
) $labels $values $functions $macros $arrays
1463 $myoptions $props $aliases $rules $gradefs
1464 $dependencies $let_rule_packages $structures
)
1465 "The list of the names of all of the information lists in Maxima."
1466 :properties
((assign 'neverset
)))
1468 (defmvar $dispflag t
1469 "If set to 'false' within a 'block' will inhibit the display of output
1470 generated by the solve functions called from within the 'block'.")
1473 "The last out-line computed, corresponds to lisp *"
1477 "In compound statements, namely 'block', 'lambda', or '(<s_1>,
1478 ...,<s_n>)', '%%' is the value of the previous statement."
1481 (defmvar $inchar
'$%i
1482 "The alphabetic prefix of the names of expressions typed by the user.")
1484 (defmvar $outchar
'$%o
1485 "The alphabetic prefix of the names of expressions returned by the
1488 (defmvar $linechar
'$%t
1489 "The alphabetic prefix of the names of intermediate displayed
1493 "The line number of the last expression."
1496 (defmvar $file_output_append nil
1497 "Flag to tell file-writing functions whether to append or clobber the
1500 (defvar *refchkl
* nil
)
1501 (defvar *mdebug
* nil
)
1502 (defvar errcatch nil
)
1503 (defvar lessorder nil
)
1504 (defvar greatorder nil
)
1505 (defvar *in-translate-file
* nil
)
1506 (defvar *linelabel
* nil
)
1508 (defvar *builtin-numeric-constants
* '($%e $%pi $%phi $%gamma
))
1509 ;;------------------------------------------------------------------------
1512 "When true, trigonometric functions are simplified to algebraic
1513 constants when the argument is an integer multiple of %pi, %pi/2,
1514 %pi/3, %pi/4, or %pi/6.")
1516 "When true, trigonometric functions are simplified to hyperbolic
1517 functions when the argument is apparently a multiple of the
1518 imaginary unit %i.")
1519 (defmvar $triginverses t
1520 "Controls the simplification of the composition of trigonometric and
1521 hyperbolic functions with their inverse functions.")
1522 (defmvar $trigexpand nil
1523 "If 'true' causes expansion of all expressions containing sin's and
1524 cos's occurring subsequently."
1525 :properties
((evflag t
)))
1526 (defmvar $trigexpandplus t
1527 "Controls the \"sum\" rule for 'trigexpand', expansion of sums (e.g.
1528 'sin(x + y)') will take place only if 'trigexpandplus' is 'true'.")
1529 (defmvar $trigexpandtimes t
1530 "Controls the \"product\" rule for 'trigexpand', expansion of
1531 products (e.g. 'sin(2 x)') will take place only if
1532 'trigexpandtimes' is 'true'.")
1533 (defmvar $trigsign t
1534 "When true, permits simplification of negative arguments to
1535 trigonometric functions.")
1536 (defmvar $exponentialize nil
1537 "When true, all circular and hyperbolic functions are converted to
1539 :properties
((evflag t
)))
1540 (defmvar $logarc nil
1541 "When true, inverse circular and hyperbolic functions are replaced by
1542 equivalent logarithmic functions."
1543 :properties
((evflag t
)))
1544 (defmvar $halfangles nil
1545 "When true, trigonometric functions of arguments '<expr>/2' are
1546 simplified to functions of <expr>."
1547 :properties
((evflag t
)))
1549 ;; Simplified shortcuts for constant expressions.
1550 (defvar %pi
//4 '((mtimes simp
) ((rat simp
) 1 4.
) $%pi
))
1551 (defvar %pi
//2 '((mtimes simp
) ((rat simp
) 1 2) $%pi
))
1552 (defvar sqrt3
//2 '((mtimes simp
)
1554 ((mexpt simp
) 3 ((rat simp
) 1 2))))
1555 (defvar -sqrt3
//2 '((mtimes simp
)
1557 ((mexpt simp
) 3 ((rat simp
) 1 2))))
1559 ;; Build hash tables '*flonum-op*' and '*big-float-op*' that map Maxima
1560 ;; function names to their corresponding Lisp functions.
1562 (defvar *flonum-op
* (make-hash-table :size
64)
1563 "Hash table mapping a maxima function to a corresponding Lisp function
1564 to evaluate the maxima function numerically with flonum precision.")
1566 (defvar *big-float-op
* (make-hash-table)
1567 "Hash table mapping a maxima function to a corresponding Lisp function
1568 to evaluate the maxima function numerically with big-float
1571 ;;------------------------------------------------------------------------
1572 ;; From init-cl.lisp
1573 (defvar $file_search_lisp nil
1574 "Directories to search for Lisp source code.")
1576 (defvar $file_search_maxima nil
1577 "Directories to search for Maxima source code.")
1579 (defvar $file_search_demo nil
1580 "Directories to search for demos.")
1582 (defvar $file_search_usage nil
)
1584 (defvar $file_search_tests nil
1585 "Directories to search for maxima test suite")
1587 (defvar *maxima-prefix
*)
1588 (defvar *maxima-infodir
*)
1589 (defvar *maxima-htmldir
*)
1590 (defvar *maxima-userdir
*)
1591 (defvar *maxima-initmac
* "maxima-init.mac"
1592 "Default maxima mac init file if none specified by the user. This
1593 file is looked for only in the maxima userdir.")
1594 (defvar *maxima-initlisp
* "maxima-init.lisp"
1595 "Default maxima lisp init file if none specified by the user. This
1596 file is looked for only in the maxima userdir")
1597 (defvar *maxima-load-init-files
* t
1598 "When non-NIL, the init files are not loaded.")
1599 (defvar *maxima-tempdir
*)
1600 (defvar *maxima-lang-subdir
* nil
)
1601 (defvar $maxima_frontend nil
1602 "The frontend maxima is used with.")
1603 (defvar $maxima_frontend_version nil
1604 "The version of the maxima frontend.")
1605 (defvar $maxima_frontend_bugreportinfo nil
1606 "The bug report info the maxima frontend comes with.")
1608 ;; A list of temporary files that can be deleted on leaving maxima
1609 (defvar *temp-files-list
* (make-hash-table :test
'equal
))
1611 ;;------------------------------------------------------------------------
1613 (defmvar $browser
"firefox '~a'"
1614 "Browser to use for displaying the documentation. This may be
1615 initialized on startup to an OS-specific value. It must contain
1616 exactly one ~a which will be replaced by the url.")
1618 (defmvar $url_base
"localhost:8080"
1619 "Base URL where the HTML doc may be found. This can be a file path
1620 like \"file:///<path>\" or a web server like \"localhost:8080\" or
1621 some other web server.
1623 This may be initialized on startup to a file path where the html
1624 files can be found.")
1626 (defmvar $output_format_for_help
'$text
1627 "The output format for help. It should be one of the values '$text,
1628 '$html, '$frontend. The default is '$text which causes the help to
1629 be sent to the terminal as plain text. '$html opens a browser to
1630 the page for the help. '$frontend assumes that some frontend will
1631 provide the necessary function to display help appropriately for the
1633 :properties
((assign 'set-output-format-for-help
)))
1635 (defvar *help-display-function
*
1636 'display-text-topics
1637 "A symbol naming the function used to display help, as determined
1638 from $output_format_for_help.")
1640 ;;------------------------------------------------------------------------
1641 (defmvar $maxima_userdir nil
1642 "Names a directory which Maxima searches to find Maxima and Lisp
1644 ;; $maxima_userdir is aliased to *maxima-userdir* so that when one
1645 ;; changes, the other does too.
1646 :properties
((assign 'shadow-string-assignment
)
1647 (lisp-shadow '*maxima-userdir
*)))
1649 (defmvar $maxima_tempdir nil
1650 "Names the directory in which Maxima creates some temporary files."
1651 :properties
((assign 'shadow-string-assignment
)
1652 (lisp-shadow '*maxima-tempdir
*)))
1654 (defmvar $maxima_objdir nil
1655 "Names the directory where fasl files are written to."
1656 :properties
((assign 'shadow-string-assignment
)
1657 (lisp-shadow '*maxima-objdir
*)))
1658 ;;------------------------------------------------------------------------
1660 (defmvar $default_let_rule_package
'$default_let_rule_package
1661 "The name of the default rule package used by `let' and `letsimp'"
1662 :properties
((assign 'let-rule-setter
)))
1664 (defmvar $current_let_rule_package
'$default_let_rule_package
1665 "The name of the current rule package used by `let' and `letsimp'"
1666 :properties
((assign 'let-rule-setter
)))
1668 ;;------------------------------------------------------------------------
1671 "If t use bmt's algebraic factoring algorithm")
1676 (defmvar minpoly
* nil
)
1680 ;;------------------------------------------------------------------------
1682 (defvar *alphabet
* (list #\_
#\%
))
1684 ;;------------------------------------------------------------------------
1686 (defvar 3//2 '((rat simp
) 3 2))
1687 (defvar 1//2 '((rat simp
) 1 2))
1688 (defvar -
1//2 '((rat simp
) -
1 2))
1690 ;;------------------------------------------------------------------------
1693 ;; generate-atan2 is set to nil when doing integration to avoid
1694 ;; generating discontinuities that defint can't handle.
1695 (defmvar generate-atan2 t
1696 "Controls whether RPART will generate ATAN's or ATAN2's, default is to
1699 (defmvar implicit-real nil
1700 "If t RPART assumes radicals and logs of real quantities are real and
1701 doesn't ask sign questions")
1703 ;;------------------------------------------------------------------------
1704 ;; From ifactor.lisp
1705 (defmvar *alpha
* nil
)
1706 (defvar *small-primes
*
1707 '(2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97
1708 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181
1709 191 193 197 199 211 223 227 229 233 239 241 251 257 263 269 271 277
1710 281 283 293 307 311 313 317 331 337 347 349 353 359 367 373 379 383
1711 389 397 401 409 419 421 431 433 439 443 449 457 461 463 467 479 487
1712 491 499 503 509 521 523 541 547 557 563 569 571 577 587 593 599 601
1713 607 613 617 619 631 641 643 647 653 659 661 673 677 683 691 701 709
1714 719 727 733 739 743 751 757 761 769 773 787 797 809 811 821 823 827
1715 829 839 853 857 859 863 877 881 883 887 907 911 919 929 937 941 947
1716 953 967 971 977 983 991 997 1009 1013 1019 1021 1031 1033 1039 1049
1717 1051 1061 1063 1069 1087 1091 1093 1097 1103 1109 1117 1123 1129 1151
1718 1153 1163 1171 1181 1187 1193 1201 1213 1217 1223 1229 1231 1237 1249
1719 1259 1277 1279 1283 1289 1291 1297 1301 1303 1307 1319 1321 1327 1361
1720 1367 1373 1381 1399 1409 1423 1427 1429 1433 1439 1447 1451 1453 1459
1721 1471 1481 1483 1487 1489 1493 1499 1511 1523 1531 1543 1549 1553 1559
1722 1567 1571 1579 1583 1597 1601 1607 1609 1613 1619 1621 1627 1637 1657
1723 1663 1667 1669 1693 1697 1699 1709 1721 1723 1733 1741 1747 1753 1759
1724 1777 1783 1787 1789 1801 1811 1823 1831 1847 1861 1867 1871 1873 1877
1725 1879 1889 1901 1907 1913 1931 1933 1949 1951 1973 1979 1987 1993 1997
1726 1999 2003 2011 2017 2027 2029 2039 2053 2063 2069 2081 2083 2087 2089
1727 2099 2111 2113 2129 2131 2137 2141 2143 2153 2161 2179 2203 2207 2213
1728 2221 2237 2239 2243 2251 2267 2269 2273 2281 2287 2293 2297 2309 2311
1729 2333 2339 2341 2347 2351 2357 2371 2377 2381 2383 2389 2393 2399 2411
1730 2417 2423 2437 2441 2447 2459 2467 2473 2477 2503 2521 2531 2539 2543
1731 2549 2551 2557 2579 2591 2593 2609 2617 2621 2633 2647 2657 2659 2663
1732 2671 2677 2683 2687 2689 2693 2699 2707 2711 2713 2719 2729 2731 2741
1733 2749 2753 2767 2777 2789 2791 2797 2801 2803 2819 2833 2837 2843 2851
1734 2857 2861 2879 2887 2897 2903 2909 2917 2927 2939 2953 2957 2963 2969
1735 2971 2999 3001 3011 3019 3023 3037 3041 3049 3061 3067 3079 3083 3089
1736 3109 3119 3121 3137 3163 3167 3169 3181 3187 3191 3203 3209 3217 3221
1737 3229 3251 3253 3257 3259 3271 3299 3301 3307 3313 3319 3323 3329 3331
1738 3343 3347 3359 3361 3371 3373 3389 3391 3407 3413 3433 3449 3457 3461
1739 3463 3467 3469 3491 3499 3511 3517 3527 3529 3533 3539 3541 3547 3557
1740 3559 3571 3581 3583 3593 3607 3613 3617 3623 3631 3637 3643 3659 3671
1741 3673 3677 3691 3697 3701 3709 3719 3727 3733 3739 3761 3767 3769 3779
1742 3793 3797 3803 3821 3823 3833 3847 3851 3853 3863 3877 3881 3889 3907
1743 3911 3917 3919 3923 3929 3931 3943 3947 3967 3989 4001 4003 4007 4013
1744 4019 4021 4027 4049 4051 4057 4073 4079 4091 4093 4099 4111 4127 4129
1745 4133 4139 4153 4157 4159 4177 4201 4211 4217 4219 4229 4231 4241 4243
1746 4253 4259 4261 4271 4273 4283 4289 4297 4327 4337 4339 4349 4357 4363
1747 4373 4391 4397 4409 4421 4423 4441 4447 4451 4457 4463 4481 4483 4493
1748 4507 4513 4517 4519 4523 4547 4549 4561 4567 4583 4591 4597 4603 4621
1749 4637 4639 4643 4649 4651 4657 4663 4673 4679 4691 4703 4721 4723 4729
1750 4733 4751 4759 4783 4787 4789 4793 4799 4801 4813 4817 4831 4861 4871
1751 4877 4889 4903 4909 4919 4931 4933 4937 4943 4951 4957 4967 4969 4973
1752 4987 4993 4999 5003 5009 5011 5021 5023 5039 5051 5059 5077 5081 5087
1753 5099 5101 5107 5113 5119 5147 5153 5167 5171 5179 5189 5197 5209 5227
1754 5231 5233 5237 5261 5273 5279 5281 5297 5303 5309 5323 5333 5347 5351
1755 5381 5387 5393 5399 5407 5413 5417 5419 5431 5437 5441 5443 5449 5471
1756 5477 5479 5483 5501 5503 5507 5519 5521 5527 5531 5557 5563 5569 5573
1757 5581 5591 5623 5639 5641 5647 5651 5653 5657 5659 5669 5683 5689 5693
1758 5701 5711 5717 5737 5741 5743 5749 5779 5783 5791 5801 5807 5813 5821
1759 5827 5839 5843 5849 5851 5857 5861 5867 5869 5879 5881 5897 5903 5923
1760 5927 5939 5953 5981 5987 6007 6011 6029 6037 6043 6047 6053 6067 6073
1761 6079 6089 6091 6101 6113 6121 6131 6133 6143 6151 6163 6173 6197 6199
1762 6203 6211 6217 6221 6229 6247 6257 6263 6269 6271 6277 6287 6299 6301
1763 6311 6317 6323 6329 6337 6343 6353 6359 6361 6367 6373 6379 6389 6397
1764 6421 6427 6449 6451 6469 6473 6481 6491 6521 6529 6547 6551 6553 6563
1765 6569 6571 6577 6581 6599 6607 6619 6637 6653 6659 6661 6673 6679 6689
1766 6691 6701 6703 6709 6719 6733 6737 6761 6763 6779 6781 6791 6793 6803
1767 6823 6827 6829 6833 6841 6857 6863 6869 6871 6883 6899 6907 6911 6917
1768 6947 6949 6959 6961 6967 6971 6977 6983 6991 6997 7001 7013 7019 7027
1769 7039 7043 7057 7069 7079 7103 7109 7121 7127 7129 7151 7159 7177 7187
1770 7193 7207 7211 7213 7219 7229 7237 7243 7247 7253 7283 7297 7307 7309
1771 7321 7331 7333 7349 7351 7369 7393 7411 7417 7433 7451 7457 7459 7477
1772 7481 7487 7489 7499 7507 7517 7523 7529 7537 7541 7547 7549 7559 7561
1773 7573 7577 7583 7589 7591 7603 7607 7621 7639 7643 7649 7669 7673 7681
1774 7687 7691 7699 7703 7717 7723 7727 7741 7753 7757 7759 7789 7793 7817
1775 7823 7829 7841 7853 7867 7873 7877 7879 7883 7901 7907 7919 7927 7933
1776 7937 7949 7951 7963 7993 8009 8011 8017 8039 8053 8059 8069 8081 8087
1777 8089 8093 8101 8111 8117 8123 8147 8161 8167 8171 8179 8191 8209 8219
1778 8221 8231 8233 8237 8243 8263 8269 8273 8287 8291 8293 8297 8311 8317
1779 8329 8353 8363 8369 8377 8387 8389 8419 8423 8429 8431 8443 8447 8461
1780 8467 8501 8513 8521 8527 8537 8539 8543 8563 8573 8581 8597 8599 8609
1781 8623 8627 8629 8641 8647 8663 8669 8677 8681 8689 8693 8699 8707 8713
1782 8719 8731 8737 8741 8747 8753 8761 8779 8783 8803 8807 8819 8821 8831
1783 8837 8839 8849 8861 8863 8867 8887 8893 8923 8929 8933 8941 8951 8963
1784 8969 8971 8999 9001 9007 9011 9013 9029 9041 9043 9049 9059 9067 9091
1785 9103 9109 9127 9133 9137 9151 9157 9161 9173 9181 9187 9199 9203 9209
1786 9221 9227 9239 9241 9257 9277 9281 9283 9293 9311 9319 9323 9337 9341
1787 9343 9349 9371 9377 9391 9397 9403 9413 9419 9421 9431 9433 9437 9439
1788 9461 9463 9467 9473 9479 9491 9497 9511 9521 9533 9539 9547 9551 9587
1789 9601 9613 9619 9623 9629 9631 9643 9649 9661 9677 9679 9689 9697 9719
1790 9721 9733 9739 9743 9749 9767 9769 9781 9787 9791 9803 9811 9817 9829
1791 9833 9839 9851 9857 9859 9871 9883 9887 9901 9907 9923 9929 9931 9941
1793 "List of small primes")
1795 ;;------------------------------------------------------------------------
1797 ;; Global variables referenced throughout the rational function package.
1799 (defmvar modulus nil
1800 "Global switch for doing modular arithmetic"
1803 ;; The modulus must be $false, or a positive integer. If the
1804 ;; value is a positive integer, print a warning if it is not
1807 (and (integerp val
) (plusp val
)
1809 (unless (primep val
)
1811 (intl:gettext
"Warning: assigning ~:M, a non-prime, to 'modulus'~&")
1814 ;; $modulus is aliased to modulus and vice-versa. Setting one, sets
1815 ;; the other to the corresponding value. MODULUS is used in Lisp
1816 ;; code; $MODULUS isn't and appears to be the Maxima interface to
1819 ;; FIXME: We should probably replace MODULUS with $MODULUS in the lisp
1820 ;; code and remove these aliases.
1821 (putprop '$modulus
'modulus
'alias
)
1822 (putprop 'modulus
'$modulus
'reversealias
)
1824 ;;------------------------------------------------------------------------
1826 (defvar radcanp nil
)
1828 ;;------------------------------------------------------------------------
1831 ;; For these variables, specfn.lisp doesn't explicitly make them
1832 ;; defvars, but does set the symbol value for these and declares them
1833 ;; special. Since these are user-visible vars defined in the manual,
1834 ;; let's make it explicit.
1835 (defmvar $maxpsiposint
20
1836 "The largest positive value for which 'psi[n](x)'will try to compute
1839 (defmvar $maxpsinegint -
10
1840 "The most negative value for which 'psi[n](x)' will try to compute an
1841 exact value. That is if <x> is less than 'maxnegint', 'psi[n](<x>)'
1842 will not return simplified answer, even if it could.")
1844 (defmvar $maxpsifracnum
6
1845 "Let <x> be a rational number less than one of the form 'p/q'. If 'p'
1846 is greater than 'maxpsifracnum', then 'psi[<n>](<x>)' will not try
1847 to return a simplified value.")
1849 (defmvar $maxpsifracdenom
6
1850 "Let <x> be a rational number less than one of the form 'p/q'. If 'q'
1851 is greater than 'maxpsifracdenom', then 'psi[<n>](<x>)' will not try
1852 to return a simplified value.")
1854 ;;------------------------------------------------------------------------
1857 "Parameter of Laplace transform.")
1859 (defvar *checkcoefsignlist
*)
1860 ;;------------------------------------------------------------------------
1861 ;; Miscellaneous vars.
1868 ;;------------------------------------------------------------------------
1869 (defvar *bindtest-deprecation-messages
* '()
1870 "An alist whose key is a symbol and datum is a cons of a string to be
1871 used with bindtest and the value of the variable. The string should
1872 contain exactly ~M which will be replaced by the variable in the
1873 error message. This is useful for printing a deprecation message