From: Robert D. <rob...@us...> - 2014-05-27 01:00:29
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Maxima CAS". The branch, master has been updated via 3d75bfd0d3339846b3508062439921bfbb37d66d (commit) via f59632ff0991b9a2c74fa6cd31e1e1e0faedf498 (commit) via 76bc90891145a50427d643d04bb883f06e0a463b (commit) via 71153ea8e1be932907834b8ded00d24227d5bbc9 (commit) via 87aa9f8fa941314d95f598285f87001074eb9911 (commit) via 325ac920ab5d348939051ee1a0d82cc235bcdfd9 (commit) via e8f4ccb6c5fa8b24d533fd6e1a97092ff29749cc (commit) via ca9431ba8d27bf52d720b2108f3ff84b34eff153 (commit) via d44924f54a2b06b60e71f300b5c54c9e89f13884 (commit) via cc9ac0348b5eae9b14f97650cd328014bc93cc96 (commit) from 707110a2b8e172cc20213b5c223b7f62364e1de2 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 3d75bfd0d3339846b3508062439921bfbb37d66d Merge: f59632f 707110a Author: Robert Dodier <rob...@us...> Date: Mon May 26 17:57:21 2014 -0700 Merge branch 'master' of ssh://git.code.sf.net/p/maxima/code commit f59632ff0991b9a2c74fa6cd31e1e1e0faedf498 Author: Robert Dodier <rob...@us...> Date: Fri May 23 10:37:29 2014 -0700 Kill postfix and prefix operators "f" and "g" to prevent them from interfering with f(x) and g(x) elsewhere. diff --git a/tests/rtest16.mac b/tests/rtest16.mac index bf48984..195dac1 100644 --- a/tests/rtest16.mac +++ b/tests/rtest16.mac @@ -1681,6 +1681,9 @@ done$ grind("g"(x)::=x); done$ +kill ("f", "g"); +done; + /* ----------------------------------------------------------------------------- * Bug ID: 3396631 - equal terms produce different results * Correcting a bug in plusin revision 23.08.2011 commit 76bc90891145a50427d643d04bb883f06e0a463b Merge: 71153ea 1204871 Author: Robert Dodier <rob...@us...> Date: Mon May 19 12:19:19 2014 -0700 Merge branch 'master' of ssh://git.code.sf.net/p/maxima/code commit 71153ea8e1be932907834b8ded00d24227d5bbc9 Merge: 87aa9f8 26856e6 Author: Robert Dodier <rob...@us...> Date: Fri May 2 15:53:37 2014 -0700 Merge branch 'master' of ssh://git.code.sf.net/p/maxima/code commit 87aa9f8fa941314d95f598285f87001074eb9911 Author: Robert Dodier <rob...@us...> Date: Fri May 2 15:52:37 2014 -0700 Bring Texinfo documentation into build system, by creating makefiles which execute makeinfo and build_index. Resulting .info and *-index.lisp files are included in this commit, although ideally they would be omitted since they are generated; however, src/sharefiles.mk is built before share, so they do not exist soon enough. The *-index.lisp files can be loaded and then their documentation items are findable via ? and ??. Ideally those index files would be loaded automatically. In order to bring a new share subdirectory into this system, it is necessary to create share/foo/Makefile.am and put foo on the SUBDIRS list in share/Makefile.am, and add share/foo/Makefile to the list of makefiles to be generated in configure.in. This is somewhat burdensome; I wonder if it can be simplified. diff --git a/configure.in b/configure.in index 9c0f869..0582ffe 100755 --- a/configure.in +++ b/configure.in @@ -1078,6 +1078,8 @@ interfaces/xmaxima/autoconf-variables.tcl interfaces/xmaxima/Tkmaxima/Header.tcl interfaces/xmaxima/doc/Makefile interfaces/xmaxima/doc/figures/Makefile \ interfaces/xmaxima/msgs/Makefile interfaces/xmaxima/win32/Makefile \ plotting/mgnuplot share/Makefile demo/Makefile plotting/Makefile locale/Makefile \ +share/contrib/Makefile share/contrib/integration/Makefile \ +share/draw/Makefile share/logic/Makefile \ src/lisp) ## Warn the user if they've asked for a pointless sys-proclaim.lisp diff --git a/share/Makefile.am b/share/Makefile.am index 3d73060..2b50bc7 100644 --- a/share/Makefile.am +++ b/share/Makefile.am @@ -7,3 +7,5 @@ genericdirDATA = \ $(sharefiles) EXTRA_DIST = $(genericdirDATA) + +SUBDIRS = contrib logic draw diff --git a/share/contrib/Makefile.am b/share/contrib/Makefile.am new file mode 100644 index 0000000..15f1a67 --- /dev/null +++ b/share/contrib/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = integration diff --git a/share/contrib/integration/Makefile.am b/share/contrib/integration/Makefile.am new file mode 100644 index 0000000..e5f112c --- /dev/null +++ b/share/contrib/integration/Makefile.am @@ -0,0 +1,9 @@ +all-local: info + +info: abs_integrate.info integration-index.lisp + +abs_integrate.info: abs_integrate.texi + makeinfo $< + +integration-index.lisp: abs_integrate.info + perl ../../../doc/info/build_index.pl $< > $@ diff --git a/share/contrib/integration/abs_integrate.info b/share/contrib/integration/abs_integrate.info new file mode 100644 index 0000000..4b32b6e --- /dev/null +++ b/share/contrib/integration/abs_integrate.info @@ -0,0 +1,318 @@ +This is abs_integrate.info, produced by makeinfo version 4.13 from abs_integrate.texi. + + +File: abs_integrate.info, Node: Top, Next: Introduction to abs_integrate, Prev: (dir), Up: (dir) + +abs_integrate +************* + +* Menu: + +* Introduction to abs_integrate:: +* Definitions for abs_integrate:: +* Function and variable index:: + +1 abs_integrate +*************** + + +File: abs_integrate.info, Node: Introduction to abs_integrate, Next: Definitions for abs_integrate, Prev: Top, Up: Top + +1.1 Introduction to abs_integrate +================================= + +The package `abs_integrate' extends Maxima's integration code to some +integrands that involve the absolute value, max, min, signum, or unit +step functions. For integrands of the form p(x) |q(x)|, where p is a +polynomial and q is a polynomial that `factor' is able to factor into a +product of linear or constant terms, the `abs_integrate' package +determines an antiderivative that is continuous on the entire real +line. Additionally, for an integrand that involves one or more +parameters, the function `conditional_integrate' tries to determine an +antiderivative that is valid for all parameter values. + + Examples To use the `abs_integrate' package, you'll first need to +load it: + (%i1) load("abs_integrate.mac")$ + + (%i2) integrate(abs(x),x); + (%o2) (x^2*signum(x))/2 + To convert (%o2) into an expression involving the absolute value +function, apply `signum_to_abs'; thus + (%i3) signum_to_abs(%); + (%o3) (x*abs(x))/2 + When the integrand has the form p(x) |x - c1| |x - c2| ... |x - cn|, +where p(x) is a polynomial and c1, c2, ..., cn are constants, the +`abs_integrate' package returns an antiderivative that is valid on the +entire real line; thus without making assumptions on a and b; for +example + (%i4) factor(convert_to_signum(integrate(abs((x-a)*(x-b)),x,a,b))); + (%o4) ((b-a)^3*signum(b-a)^2)/6 + + Additionally, `abs_integrate' is able to find antiderivatives of some +integrands involving `max, min, signum', and `unit_step'; examples: + (%i5) integrate(max(x,x^2),x); + (%o5) signum(x-1)*((x^3*signum(x))/6-1/6)+signum(x-1)*(1/4-(x^2*signum(x))/4)+x^3/6+x^2/4 + + (%i6) integrate(signum(x) - signum(1-x),x); + (%o6) x*signum(x)+(x-1)*signum(x-1) + A plot indicates that indeed (%o5) and (%o6) are continuous at zero +and at one. + + For definite integrals with numerical integration limits (including +both minus and plus infinity), the `abs_integrate' package converts the +integrand to signum form and then it tries to subdivide the integration +region so that the integrand simplifies to a non-signum expression on +each subinterval; for example + (%i1) integrate(1 / (1 + abs(x-5)),x,-5,6); + (%o1) log(11)+log(2) + + Finally, `abs_integrate' is able to determine antiderivatives of +_some_ functions of the form F(x, |x - a|); examples + (%i2) integrate(1/(1 + abs(x)),x); + (%o2) ((signum(x)+1)*log(x+1))/2-(log(1-x)*(1-signum(x)))/2 + + (%i3) integrate(cos(x + abs(x)),x); + (%o3) ((signum(x)+1)*sin(2*x)-2*x*signum(x)+2*x)/4 + + Barton Willis (Professor of Mathematics, University of Nebraska at +Kearney) wrote the `abs_integrate' package and its English language +user documentation. This documentation also describes the `partition' +package for integration. Richard Fateman wrote `partition'. Additional +documentation for `partition' is located at +http://www.cs.berkeley.edu/~fateman/papers/partition.pdf. + + To use `load(abs_integrate)' + + +File: abs_integrate.info, Node: Definitions for abs_integrate, Next: Function and variable index, Prev: Introduction to abs_integrate, Up: Top + +1.2 Definitions for abs_integrate +================================= + + -- Option: extra_integration_methods + Default value: `['signum_int, 'abs_integrate_use_if]' + + The list `extra_integration_methods' is a list of functions for + integration. When `integrate' is unable to find an antiderivative, + Maxima uses the methods in `extra_integration_methods' to attempt + to determine an antiderivative. + + Each function `f' in `extra_integration_methods' should have the + form `f(integrand, variable)'. The function `f' may either return + `false' to indicate failure, or it may return an expression + involving an integration noun form. The integration methods are + tried from the first to the last member of + `extra_integration_methods'; when no method returns an expression + that does not involve an integration noun form, the value of the + integral is the last value that does not fail (or a pure noun form + if all methods fail). + + When the function `abs_integrate_use_if' is successful, it returns + a conditional expression; for example + (%i2) integrate(1/(1 + abs(x+1) + abs(x-1)),x); + (%o2) %if(-(x+1)>0,-log(1-2*x)/2+log(3)-2/3,%if(-(x-1)>0,x/3+log(3)/2-1/3,log(2*x+1)/2)) + + (%i3) integrate(exp(-abs(x-1) - abs(x)),x); + (%o3) %if(-x>0,%e^(2*x-1)/2-2*%e^(-1),%if(-(x-1)>0,%e^(-1)*x-(3*%e^(-1))/2,-%e^(1-2*x)/2)) + For definite integration, these conditional expressions can cause + trouble: + (%i4) integrate(exp(-abs(x-1) - abs(x)),x, minf,inf); + (%o4) limit(%if(-x>0,(%e^(-1)*(%e^(2*x)-4))/2,%if(-(x-1)>0,(%e^(-1)*(2*x-3))/2,-%e^(1-2*x)/2)),x,inf,minus)-limit(%if(-x>0,(%e^(-1)*(%e^(2*x)-4))/2,%if(-(x-1)>0,(%e^(-1)*(2*x-3))/2,-%e^(1-2*x)/2)),x,-inf,plus) + For such definite integrals, try disallowing the method + `abs_integrate_use_if': + (%i9) integrate(exp(-abs(x-1) - abs(x)),x, minf,inf), extra_integration_methods : ['signum_int]; + (%o9) 2*%e^(-1) + + Related options extra_definite_integration_methods + + To use `load(abs_integrate)' + + + -- Option: extra_definite_integration_methods + Default value: `['abs_defint]' + + The list `extra_definite_integration_methods' is a list of extra + functions for definite integration. When `integrate' is unable to + find a definite integral, Maxima uses the methods in + `extra_definite_integration_methods' to attempt to determine an + antiderivative. + + Each function `f' in `extra_definite_integration_methods' should + have the form `f(integrand, variable, lo, hi)', where `lo' and + `hi' are the lower and upper limits of integration, respectively. + The function `f' may either return `false' to indicate failure, or + it may return an expression involving an integration noun form. + The integration methods are tried from the first to the last + member of `extra_definite_integration_methods'; when no method + returns an expression that does not involve an integration noun + form, the value of the integral is the last value that does not + fail (or a pure noun form if all methods fail). + + Related options extra_integration_methods + + To use `load(abs_integrate)' + + + -- Function: intfudu(<e>, <x>) + This function uses the derivative divides rule for integrands of + the form f(w(x)) * diff(w(x),x) When `infudu' is unable to find an + antiderivative, it returns false. + + (%i1) intfudu(cos(x^2) * x,x); + (%o1) sin(x^2)/2 + + (%i3) intfudu(x * sqrt(1+x^2),x); + (%o3) (x^2+1)^(3/2)/3 + + (%i4) intfudu(x * sqrt(1 + x^4),x); + (%o4) false + + For the last example, the derivative divides rule fails, so + `intfudu' returns false. + + A hashed array `intable' contains the antiderivative data. To + append a fact to the hash table, say integrate(f) = g, do this: + + (%i1) intable[f] : lambda([u], [g(u),diff(u,%voi)]); + (%o1) lambda([u],[g(u),diff(u,%voi)]) + + (%i2) intfudu(f(z),z); + (%o2) g(z) + + (%i3) intfudu(f(w(x)) * diff(w(x),x),x); + (%o3) g(w(x)) + + An alternative to calling `intfudu' directly is to use the + `extra_integration_methods' mechanism; an example: + (%i1) load("abs_integrate.mac")$ + (%i2) load(basic)$ + (%i3) load("partition.mac")$ + + (%i4) integrate(bessel_j(1,x^2) * x,x); + (%o4) integrate(bessel_j(1,x^2)*x,x) + + (%i5) push('intfudu, extra_integration_methods)$ + + (%i6) integrate(bessel_j(1,x^2) * x,x); + (%o6) -bessel_j(0,x^2)/2 + + To use `load(partition)' + + Additional documentation + http://www.cs.berkeley.edu/~fateman/papers/partition.pdf + + Related functions intfugudu + + + -- Function: intfugudu (<e>, <x>) + This function uses the derivative divides rule for integrands of + the form f(w(x)) * g(w(x)) * diff(w(x),x). When `infudu' is unable + to find an antiderivative, it returns false. + + (%i1) diff(jacobi_sn(x,2/3),x); + (%o1) jacobi_cn(x,2/3)*jacobi_dn(x,2/3) + + (%i2) intfugudu(%,x); + (%o2) jacobi_sn(x,2/3) + + (%i3) diff(jacobi_dn(x^2,a),x); + (%o3) -2*a*x*jacobi_cn(x^2,a)*jacobi_sn(x^2,a) + + (%i4) intfugudu(%,x); + (%o4) jacobi_dn(x^2,a) + + For a method for automatically calling `infugudu' from + `integrate', see the documentation for `intfudu'. + + To use `load(partition)' + + Additional documentation + http://www.cs.berkeley.edu/~fateman/papers/partition.pdf + + Related functions intfudu + + + -- Function: signum_to_abs (<e>) + This function replaces subexpressions of the form q signum(q) by + abs(q). Before it does these substitutions, it replaces + subexpressions of the form signum(p) * signum(q) by signum(p * q); + examples: + + (%i1) map('signum_to_abs, [x * signum(x), x * y * signum(x)* signum(y)/2]); + (%o1) [abs(x),(abs(x)*abs(y))/2] + To use `load(abs_integrate)' + + + -- Function: conditional_integrate (<e>, <x>) + For an integrand with one or more parameters, this function tries + to determine an antiderivative that is valid for all parameter + values. When successful, this function returns a conditional + expression for the antiderivative. + + (%i1) conditional_integrate(cos(m*x),x); + (%o1) %if(m#0,sin(m*x)/m,x) + + (%i2) conditional_integrate(cos(m*x)*cos(x),x); + (%o2) %if((m-1#0) %and (m+1#0),-((m-1)*cos((m+1)*x)+(m+1)*cos((m-1)*x))/(2*m^2-2),(sin(2*x)+2*x)/4) + + (%i3) sublis([m=6],%); + (%o3) -(5*cos(7*x)+7*cos(5*x))/70 + + (%i4) conditional_integrate(exp(a*x^2+b*x),x); + (%o4) %if(a#0,-(sqrt(%pi)*%e^(-b^2/(4*a))*erf((2*a*x+b)/(2*sqrt(-a))))/(2*sqrt(-a)),%if(b#0,%e^(b*x)/b,x)) + + + -- Function: convert_to_signum (<e>) + This function replaces subexpressions of the form abs(q), + unit_step(q), min(q1,q2, ..., qn) and max(q1,q2, ..., qn) by + equivalent signum terms. + + (%i1) map('convert_to_signum, [abs(x), unit_step(x), max(a,2), min(a,2)]); + (%o1) [x*signum(x),(signum(x)+1)/2,((a-2)*signum(a-2)+a+2)/2,(-(a-2)*signum(a-2)+a+2)/2] + + To convert `unit_step' to signum form, the function + `convert_to_signum' uses unit_step(x) = (1 + signum(x))/2. + + To use `load(abs_integrate)' + + Related functions signum_to_abs + + + +File: abs_integrate.info, Node: Function and variable index, Prev: Definitions for abs_integrate, Up: Top + +Appendix A Function and variable index +************************************** + ++* Menu: + +* conditional_integrate: Definitions for abs_integrate. + (line 161) +* convert_to_signum: Definitions for abs_integrate. + (line 180) +* intfudu: Definitions for abs_integrate. + (line 71) +* intfugudu: Definitions for abs_integrate. + (line 122) +* signum_to_abs: Definitions for abs_integrate. + (line 150) + ++* Menu: + +* extra_definite_integration_methods: Definitions for abs_integrate. + (line 46) +* extra_integration_methods: Definitions for abs_integrate. + (line 7) + + + +Tag Table: +Node: Top0 +Node: Introduction to abs_integrate364 +Node: Definitions for abs_integrate3489 +Node: Function and variable index11051 + +End Tag Table diff --git a/share/contrib/integration/integration-index.lisp b/share/contrib/integration/integration-index.lisp new file mode 100644 index 0000000..7989b6f --- /dev/null +++ b/share/contrib/integration/integration-index.lisp @@ -0,0 +1,18 @@ +(in-package :cl-info) +(let ( +(deffn-defvr-pairs '( +; CONTENT: (<INDEX TOPIC> . (<FILENAME> <BYTE OFFSET> <LENGTH IN CHARACTERS> <NODE NAME>)) +("conditional_integrate" . ("abs_integrate.info" 9663 804 "Definitions for abs_integrate")) +("convert_to_signum" . ("abs_integrate.info" 10469 582 "Definitions for abs_integrate")) +("extra_definite_integration_methods" . ("abs_integrate.info" 5740 1133 "Definitions for abs_integrate")) +("extra_integration_methods" . ("abs_integrate.info" 3708 2030 "Definitions for abs_integrate")) +("intfudu" . ("abs_integrate.info" 6875 1539 "Definitions for abs_integrate")) +("intfugudu" . ("abs_integrate.info" 8416 824 "Definitions for abs_integrate")) +("signum_to_abs" . ("abs_integrate.info" 9242 419 "Definitions for abs_integrate")) +)) +(section-pairs '( +; CONTENT: (<NODE NAME> . (<FILENAME> <BYTE OFFSET> <LENGTH IN CHARACTERS>)) +("Definitions for abs_integrate" . ("abs_integrate.info" 3639 7412)) +("Introduction to abs_integrate" . ("abs_integrate.info" 490 2999)) +))) +(load-info-hashtables (pathname-directory #-gcl *load-pathname* #+gcl sys:*load-pathname*) deffn-defvr-pairs section-pairs)) diff --git a/share/draw/Makefile.am b/share/draw/Makefile.am new file mode 100644 index 0000000..73bbde2 --- /dev/null +++ b/share/draw/Makefile.am @@ -0,0 +1,9 @@ +all-local: info + +info: drawutils.info draw-index.lisp + +drawutils.info: drawutils.texi + makeinfo $< + +draw-index.lisp: drawutils.info + perl ../../doc/info/build_index.pl $< > $@ diff --git a/share/draw/draw-index.lisp b/share/draw/draw-index.lisp new file mode 100644 index 0000000..f72965c --- /dev/null +++ b/share/draw/draw-index.lisp @@ -0,0 +1,11 @@ +(in-package :cl-info) +(let ( +(deffn-defvr-pairs '( +; CONTENT: (<INDEX TOPIC> . (<FILENAME> <BYTE OFFSET> <LENGTH IN CHARACTERS> <NODE NAME>)) +("plot_vector_field" . ("drawutils.info" 762 769 "Vector fields")) +("plot_vector_field3d" . ("drawutils.info" 1533 861 "Vector fields")) +)) +(section-pairs '( +; CONTENT: (<NODE NAME> . (<FILENAME> <BYTE OFFSET> <LENGTH IN CHARACTERS>)) +))) +(load-info-hashtables (pathname-directory #-gcl *load-pathname* #+gcl sys:*load-pathname*) deffn-defvr-pairs section-pairs)) diff --git a/share/draw/drawutils.info b/share/draw/drawutils.info new file mode 100644 index 0000000..6ec2bb3 Binary files /dev/null and b/share/draw/drawutils.info differ diff --git a/share/logic/Makefile.am b/share/logic/Makefile.am new file mode 100644 index 0000000..fbb945d --- /dev/null +++ b/share/logic/Makefile.am @@ -0,0 +1,9 @@ +all-local: info + +info: logic.info logic-index.lisp + +logic.info: logic.texi + makeinfo --force logic.texi + +logic-index.lisp: logic.info + perl ../../doc/info/build_index.pl $< > $@ diff --git a/share/logic/logic-index.lisp b/share/logic/logic-index.lisp new file mode 100644 index 0000000..a228581 --- /dev/null +++ b/share/logic/logic-index.lisp @@ -0,0 +1,28 @@ +(in-package :cl-info) +(let ( +(deffn-defvr-pairs '( +; CONTENT: (<INDEX TOPIC> . (<FILENAME> <BYTE OFFSET> <LENGTH IN CHARACTERS> <NODE NAME>)) +("boolean_form" . ("logic.info" 11698 539 "Definitions for logic")) +("characteristic_vector" . ("logic.info" 3148 1295 "Definitions for logic")) +("closed_under_f" . ("logic.info" 6521 396 "Definitions for logic")) +("closed_under_t" . ("logic.info" 6919 393 "Definitions for logic")) +("demorgan" . ("logic.info" 12239 378 "Definitions for logic")) +("dual_function" . ("logic.info" 5725 351 "Definitions for logic")) +("functionally_complete" . ("logic.info" 9051 625 "Definitions for logic")) +("linear" . ("logic.info" 8447 602 "Definitions for logic")) +("logic_basis" . ("logic.info" 9678 1436 "Definitions for logic")) +("logic_diff" . ("logic.info" 11116 580 "Definitions for logic")) +("logic_equiv" . ("logic.info" 4994 729 "Definitions for logic")) +("logic_simp" . ("logic.info" 2487 659 "Definitions for logic")) +("monotonic" . ("logic.info" 7314 1131 "Definitions for logic")) +("pcnf" . ("logic.info" 12866 224 "Definitions for logic")) +("pdnf" . ("logic.info" 12619 245 "Definitions for logic")) +("self_dual" . ("logic.info" 6078 441 "Definitions for logic")) +("zhegalkin_form" . ("logic.info" 4445 547 "Definitions for logic")) +)) +(section-pairs '( +; CONTENT: (<NODE NAME> . (<FILENAME> <BYTE OFFSET> <LENGTH IN CHARACTERS>)) +("Definitions for logic" . ("logic.info" 2434 10656)) +("Introduction to logic" . ("logic.info" 386 1922)) +))) +(load-info-hashtables (pathname-directory #-gcl *load-pathname* #+gcl sys:*load-pathname*) deffn-defvr-pairs section-pairs)) diff --git a/share/logic/logic.info b/share/logic/logic.info index 58bad0d..4dbd404 100644 --- a/share/logic/logic.info +++ b/share/logic/logic.info @@ -1,28 +1,441 @@ -\input texinfo -@c logic.mac--Logic algebra package for Maxima CAS. -@c Copyright (c) 2008--2009 Alexey Beshenov <al...@be...>. -@c -@c Version 2.1. Last modified 2009-01-07 -@c -@c logic.mac is free software; you can redistribute it and/or modify it -@c under the terms of the GNU Lesser General Public License as published -@c by the Free Software Foundation; either version 2.1 of the License, -@c or (at your option) any later version. -@c -@c logic.mac is distributed in the hope that it will be useful, but -@c WITHOUT ANY WARRANTY; without even the implied warranty of -@c MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -@c General Public License for more details. -@c -@c You should have received a copy of the GNU General Public License -@c along with the logic.mac; see the file COPYING. If not, write to the -@c Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -@c Boston, MA 02110-1301, USA. - - -@setfilename logic.info -@settitle Logic algebra package for Maxima - -@include logic.texi - -@bye +This is logic.info, produced by makeinfo version 4.13 from logic.texi. + + +File: logic.info, Node: Top, Next: Introduction to logic, Prev: (dir), Up: (dir) + +logic +***** + +* Menu: + +* Introduction to logic:: +* Definitions for logic:: +* Function and variable index:: + +1 logic +******* + + +File: logic.info, Node: Introduction to logic, Next: Definitions for logic, Prev: Top, Up: Top + +1.1 Introduction to logic +========================= + +This is a draft version of logic algebra package for Maxima. It is +being developed by Alexey Beshenov (al...@be...). All source code +is available uder the terms of GNU GPL 2.1. + + List of recognized operators: + +Operator Type Binding Description Properties + power +---------------------------------------------------------------------------- +`not' Prefix `70' Logical NOT (negation) +`and' N-ary `65' Logical AND (conjunction) Commutative +`nand' N-ary `62' Sheffer stroke (alternative Commutative + denial, NAND) +`nor' N-ary `61' Webb-operation or Peirce arrow Commutative + (Quine's dagger, NOR) +`or' N-ary `60' Logical OR (disjunction) Commutative +`implies' Infix `59' Implication +`eq' N-ary `58' Equivalence Commutative +`xor' N-ary `58' Sum modulo 2 (exclusive or) Commutative + +1.2 TeX output +============== + +logic.mac assigns the following TeX output: + +`not' + `\neg' + +`and' + `\wedge' + +`nand' + `\mid' + +`nor' + `\downarrow' + +`or' + `\vee' + +`implies' + `\rightarrow' + +`eq' + `\sim' + +`xor' + `\oplus' + + Examples: + + (%i1) load ("logic.mac")$ + (%i2) tex (a implies b)$ + $$a \rightarrow b$$ + (%i3) tex ((a nor b) nand c)$ + $$\left(a \downarrow b\right) \mid c$$ + (%i4) tex (zhegalkin_form (a or b or c))$ + $$a \wedge b \wedge c \oplus a \wedge b \oplus a \wedge c \oplus b + \wedge c \oplus a \oplus b \oplus c$$ + (%i5) tex (boolean_form (a implies b implies c)); + $$ \neg \left( \neg a \vee b\right) \vee c$$ + (%i6) tex (a eq b eq c); + $$a \sim b \sim c$$ + + + +File: logic.info, Node: Definitions for logic, Next: Function and variable index, Prev: Introduction to logic, Up: Top + +1.3 Definitions for logic +========================= + + -- Function: logic_simp (<expr>) + Returns a simplified version of logical expression <expr>. + + Examples: + + (%i1) load ("logic.mac")$ + (%i2) logic_simp (a or (b or false or (a or b))); + (%o2) a or b + (%i3) logic_simp (b eq a eq false eq true); + (%o3) eq a eq b false + (%i4) logic_simp ((a xor true) xor b xor true); + (%o4) a xor b + + The function applies only basic simplification rules without + introducing new functions. + + N.B. It should be merged somehow with the basic Maxima simplifier. + + -- Function: characteristic_vector (<expr>, <var_1>, ..., <var_n>) + Returns a list of size 2^n with all possible values of <expr>. + + For example, `characteristic_vector (f(x,y,z), x, y, z)' is + equivalent to list + + [ + f (false, false, false), + f (false, false, true), + f (false, true, false), + f (false, true, true), + f ( true, false, false), + f ( true, false, true), + f ( true, true, false), + f ( true, true, true) + ] + + If `<var_1>, ..., <var_n>' is omitted, it is assumed that + + [<var_1>, ..., <var_n>] = sort(listofvars(<expr>)) + + Examples: + + (%i1) load ("logic.mac")$ + (%i2) characteristic_vector (true); + (%o2) [true] + (%i3) characteristic_vector (a xor b); + (%o3) [false, true, true, false] + (%i4) characteristic_vector (a implies b); + (%o4) [true, true, false, true] + (%i5) characteristic_vector (a implies b, a, b); + (%o5) [true, true, false, true] + (%i6) characteristic_vector (a implies b, b, a); + (%o6) [true, false, true, true] + + -- Function: zhegalkin_form (<expr>) + Returns the representation of <expr> in Zhegalkin basis `{xor, + and, true}'. + + Examples: + + (%i1) load ("logic.mac")$ + (%i2) zhegalkin_form (a or b or c); + (%o2) (a and b and c) xor (a and b) xor (a and c) + xor (b and c) xor a xor b xor c + (%i3) zhegalkin_form ((a implies b) or c); + (%o3) (a and b and c) xor (a and b) xor (a and c) xor a + xor true + + -- Function: logic_equiv (<expr_1>, <expr_2>) + Returns `true' if <expr_1> is equivalent to <expr_2> and `false' + otherwise. + + Examples: + + (%i1) load ("logic.mac")$ + (%i2) e : ((a or b) xor c) and d$ + (%i3) zhegalkin_form (e); + (%o3) (a and b and d) xor (a and d) xor (b and d) + xor (c and d) + (%i4) logic_equiv (%i2, %o3); + (%o4) true + (%i5) is (characteristic_vector(%i2) = characteristic_vector(%o3)); + (%o5) true + (%i6) logic_equiv (x and y eq x, x implies y); + (%o6) true + + -- Function: dual_function (<expr>) + dual_function (f (x_1, ..., x_n)) := not f (not x_1, ..., not x_n). + + Example: + + (%i1) load ("logic.mac")$ + (%i2) dual_function (x or y); + (%o2) not ((not x) or (not y)) + (%i3) demorgan (%); + (%o3) x and y + + -- Function: self_dual (<expr>) + Returns `true' if <expr> is equivalent to `dual_function (<expr>)' + and `false' otherwise. + + Examples: + + (%i1) load ("logic.mac")$ + (%i2) self_dual (a); + (%o2) true + (%i3) self_dual (not a); + (%o3) true + (%i4) self_dual (a eq b); + (%o4) false + + -- Function: closed_under_f (<expr>) + `closed_under_f (f (x_1, ..., x_n)' returns `true' if `f (false, + ..., false) = false' and `false' otherwise. + + Examples: + + (%i1) load ("logic.mac")$ + (%i2) closed_under_f (x and y); + (%o2) true + (%i3) closed_under_f (x or y); + (%o3) true + + -- Function: closed_under_t (<expr>) + `closed_under_t (f (x_1, ..., x_n)' returns `true' if `f (true, + ..., true) = true' and `false' otherwise. + + Examples: + + (%i1) load ("logic.mac")$ + (%i2) closed_under_t (x and y); + (%o2) true + (%i3) closed_under_t (x or y); + (%o3) true + + -- Function: monotonic (<expr>) + Returns `true' if characteristic vector of <expr> is monotonic, + i.e. + + charvec : characteristic_vector(expr) + charvec[i] <= charvec[i+1], i = 1, ..., n-1 + + where `a<=b := (a=b or (a=false and b=true))'. + + Examples: + + (%i1) load ("logic.mac")$ + (%i2) monotonic (a or b); + (%o2) true + (%i3) monotonic (a and b); + (%o3) true + (%i4) monotonic (a implies b); + (%o4) false + (%i5) monotonic (a xor b); + (%o5) false + (%i6) characteristic_vector (a or b); + (%o6) [false, true, true, true] + (%i7) characteristic_vector (a and b); + (%o7) [false, false, false, true] + (%i8) characteristic_vector (a implies b); + (%o8) [true, true, false, true] + (%i9) characteristic_vector (a xor b); + (%o9) [false, true, true, false] + + -- Function: linear (<expr>) + Returns `true' if `zhegalkin_form(<expr>)' is linear and `false' + otherwise. + + Examples: + + (%i1) load ("logic.mac")$ + (%i2) linear (a or b); + (%o2) false + (%i3) linear (a eq b); + (%o3) true + (%i4) zhegalkin_form (a or b); + (%o4) (a and b) xor a xor b + (%i5) zhegalkin_form (a eq b); + (%o5) a xor b xor true + + Linear functions are also known as counting or alternating + functions. + + -- Function: functionally_complete (<expr_1>, ..., <expr_n>) + Returns `true' if <expr_1>, ..., <expr_n> is a functionally + complete system and `false' otherwise. The constants are + essential (see the example below). + + Examples: + + (%i1) load ("logic.mac")$ + (%i2) functionally_complete (x and y, x xor y); + (%o2) false + (%i3) functionally_complete (x and y, x xor y, true); + (%o3) true + (%i4) functionally_complete (x and y, x or y, not x); + (%o4) true + + -- Function: logic_basis (<expr_1>, ..., <expr_n>) + Returns `true' if <expr_1>, ..., <expr_n> is a functionally + complete system without redundant elements and `false' otherwise. + + Examples: + + (%i1) load ("logic.mac")$ + (%i2) logic_basis (x and y, x or y); + (%o2) false + (%i3) logic_basis (x and y, x or y, not x); + (%o3) false + (%i4) logic_basis (x and y, not x); + (%o4) true + (%i5) logic_basis (x or y, not x); + (%o5) true + (%i8) logic_basis (x and y, x xor y, true); + (%o8) true + + All possible bases: + + (%i1) load ("logic.mac")$ + (%i2) logic_functions : { not x, x nand y, x nor y, + x implies y, x and y, x or y, + x eq y, x xor y, true, false }$ + (%i3) subset (powerset(logic_functions), + lambda ([s], apply ('logic_basis, listify(s)))); + (%o3) {{false, x eq y, x and y}, {false, x eq y, x or y}, + {false, x implies y}, {true, x xor y, x and y}, + {true, x xor y, x or y}, {not x, x implies y}, + {not x, x and y}, {not x, x or y}, + {x eq y, x xor y, x and y}, {x eq y, x xor y, x or y}, + {x implies y, x xor y}, {x nand y}, {x nor y}} + + -- Function: logic_diff (<f>, <x>) + Returns the logic derivative df/dx of f wrt x. + + logic_diff (f (x_1, ..., x_k, ..., x_n), x_k) := + f (x_1, ..., true, ..., x_n) xor + f (x_1, ..., false, ..., x_n) + + Examples: + + (%i1) load ("logic.mac")$ + (%i2) logic_diff (a or b or c, a); + (%o2) (b and c) xor b xor c xor true + (%i3) logic_diff (a and b and c, a); + (%o3) b and c + (%i4) logic_diff (a or (not a), a); + (%o4) false + + -- Function: boolean_form (<expr>) + Returns the representation of <expr> in Boolean basis `{and, or, + not}'. + + Examples: + + (%i1) load ("logic.mac")$ + (%i2) boolean_form (a implies b implies c); + (%o2) (not ((not a) or b)) or c + (%i3) demorgan (%); + (%o3) ((not b) and a) or c + (%i4) logic_equiv (boolean_form (a implies b implies c), + zhegalkin_form (a implies b implies c)); + (%o4) true + + -- Function: demorgan (<expr>) + Applies De Morgan's rules to <expr>: + + not (x_1 and ... and x_n) => (not x_1 or ... or not x_n) + not (x_1 or ... or x_n) => (not x_1 and ... and not x_n) + + Example: + + (%i1) load ("logic.mac")$ + (%i2) demorgan (boolean_form (a nor b nor c)); + (%o2) (not a) and (not b) and (not c) + + -- Function: pdnf (<expr>) + Returns the perfect disjunctive normal form of <expr>. + + Example: + + (%i1) load ("logic.mac")$ + (%i2) pdnf (x implies y); + (%o2) (x and y) or ((not x) and y) or ((not x) and (not y)) + + -- Function: pcnf (<expr>) + Returns the perfect conjunctive normal form of <expr>. + + Example: + + (%i1) load ("logic.mac")$ + (%i2) pcnf (x implies y); + (%o2) (not x) or y + + +File: logic.info, Node: Function and variable index, Prev: Definitions for logic, Up: Top + +Appendix A Function and variable index +************************************** + ++* Menu: + +* boolean_form: Definitions for logic. + (line 254) +* characteristic_vector: Definitions for logic. + (line 25) +* closed_under_f: Definitions for logic. + (line 117) +* closed_under_t: Definitions for logic. + (line 129) +* demorgan: Definitions for logic. + (line 269) +* dual_function: Definitions for logic. + (line 92) +* functionally_complete: Definitions for logic. + (line 189) +* linear: Definitions for logic. + (line 170) +* logic_basis: Definitions for logic. + (line 204) +* logic_diff: Definitions for logic. + (line 237) +* logic_equiv: Definitions for logic. + (line 74) +* logic_simp: Definitions for logic. + (line 7) +* monotonic: Definitions for logic. + (line 141) +* pcnf: Definitions for logic. + (line 290) +* pdnf: Definitions for logic. + (line 281) +* self_dual: Definitions for logic. + (line 103) +* zhegalkin_form: Definitions for logic. + (line 60) + ++* Menu: + + +Tag Table: +Node: Top0 +Node: Introduction to logic284 +Node: Definitions for logic2308 +Node: Function and variable index13090 + +End Tag Table diff --git a/src/sharefiles.mk b/src/sharefiles.mk index 30bd729..4025b3d 100644 --- a/src/sharefiles.mk +++ b/src/sharefiles.mk @@ -332,9 +332,11 @@ contrib/Grobner/README \ contrib/impdiff.mac \ contrib/implicit_plot.lisp \ contrib/integration/abs_integrate.html \ +contrib/integration/abs_integrate.info \ contrib/integration/abs_integrate.mac \ contrib/integration/abs_integrate.texi \ contrib/integration/hyperint.mac \ +contrib/integration/integration-index.lisp \ contrib/integration/partition.mac \ contrib/integration/rtest_abs_integrate.mac \ contrib/levin/levin.dem \ @@ -537,8 +539,10 @@ distrib/distrib.mac \ distrib/numdistrib.lisp \ distrib/rtest_distrib.mac \ draw/draw_gnuplot.dem \ +draw/draw-index.lisp \ draw/draw.lisp \ draw/draw.system \ +draw/drawutils.info \ draw/drawutils.mac \ draw/drawutils.texi \ draw/gnuplot.lisp \ @@ -876,6 +880,7 @@ linearalgebra/test-polynomialp.mac \ logic/COPYING \ logic/logic.dem \ logic/logic.html \ +logic/logic-index.lisp \ logic/logic.info \ logic/logic.lisp \ logic/logic.mac \ commit 325ac920ab5d348939051ee1a0d82cc235bcdfd9 Author: Robert Dodier <rob...@us...> Date: Thu May 1 18:47:17 2014 -0700 Revise logic.texi to adopt conventions of share/template-standalone.texi so that documentation items can (eventually) be indexed and loaded by help system. diff --git a/share/logic/logic.texi b/share/logic/logic.texi index e3a16cc..cc86ccf 100644 --- a/share/logic/logic.texi +++ b/share/logic/logic.texi @@ -18,9 +18,26 @@ @c Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, @c Boston, MA 02110-1301, USA. -@top Logic algebra package for Maxima - -@section Introduction +@setfilename logic.info +@settitle logic + +@ifinfo +@macro var {expr} +<\expr\> +@end macro +@end ifinfo + +@node Top, Introduction to logic, (dir), (dir) +@top +@menu +* Introduction to logic:: +* Definitions for logic:: +* Function and variable index:: +@end menu +@chapter logic + +@node Introduction to logic, Definitions for logic, Top, Top +@section Introduction to logic This is a draft version of logic algebra package for Maxima. It is being developed by Alexey@tie{}Beshenov@tie{}(al@@beshenov.ru). @@ -133,8 +150,8 @@ $$ \neg \left( \neg a \vee b\right) \vee c$$ $$a \sim b \sim c$$ @end tex -@section Functions for logic algebra - +@node Definitions for logic, Function and variable index, Introduction to logic, Top +@section Definitions for logic @deffn {Function} logic_simp (@var{expr}) @@ -624,3 +641,10 @@ Example: @end group @end example @end deffn + +@node Function and variable index, , Definitions for logic, Top +@appendix Function and variable index +@printindex fn +@printindex vr + +@bye commit e8f4ccb6c5fa8b24d533fd6e1a97092ff29749cc Author: Robert Dodier <rob...@us...> Date: Wed Apr 30 19:51:58 2014 -0700 Remove share/contrib/unit/unit.texi, since it appears to be superseded by doc/info/unit.texi. diff --git a/share/contrib/unit/unit.texi b/share/contrib/unit/unit.texi deleted file mode 100644 index 346b559..0000000 --- a/share/contrib/unit/unit.texi +++ /dev/null @@ -1,505 +0,0 @@ -@menu -* Introduction to Units:: -* Definitions for Units:: -@end menu - -@node Introduction to Units, Definitions for Units, Units, Units -@section Introduction to Units - -The @emph{unit} package enables the user to convert between arbitrary -units and work with dimensions in equations. The functioning of this package -is radically different from the original Maxima units package - whereas the -original was a basic list of definitions, this package uses rulesets to allow -the user to chose, on a per dimension basis, what unit final answers should be -rendered in. It will separate units instead of intermixing them in the display, -allowing the user to readily identify the units associated with a particular -answer. It will allow a user to simplify an expression to its fundamental Base -Units, as well as providing fine control over simplifying to derived units. -Dimensional analysis is possible, and a variety of tools are available to -manage conversion and simplification options. In addition to customizable -automatic conversion, @emph{units} also provides a traditional manual -conversion option. - -Note - when unit conversions are inexact Maxima will make approximations resulting -in fractions. This is a consequence of the techniques used to simplify units. -The messages warning of this type of substitution are disabled by default in -the case of units (normally they are on) since this situation occurs frequently -and the warnings clutter the output. (The existing state of ratprint is restored -after unit conversions, so user changes to that setting will be preserved -otherwise.) If the user needs this information for units, they can set -@emph{unitverbose:on} to reactivate the printing of warnings from the unit -conversion process. - -@subsubsection Loading @emph{unit} - -@emph{unit} is included in Maxima in the share/contrib/unit directory. It obeys -normal Maxima package loading conventions: - -@example -(%i1) load("share/contrib/unit.mac"); -******************************************************************* -* Units version 0.50 * -* Definitions based on the NIST Reference on * -* Constants, Units, and Uncertainty * -* Conversion factors from various sources including * -* NIST and the GNU units package * -******************************************************************* - -Redefining necessary functions... -STYLE-WARNING: redefining TOPLEVEL-MACSYMA-EVAL in DEFUN -STYLE-WARNING: redefining MSETCHK in DEFUN -STYLE-WARNING: redefining KILL1 in DEFUN -STYLE-WARNING: redefining NFORMAT in DEFUN -Initializing unit arrays... -Done. -(%o1) /usr/local/share/maxima/5.9.1.1cvs/share/contrib/unit/unit.mac -@end example - -The STYLE-WARNING messages are expected and not a cause for concern - they indicate -the @emph{unit} package is redefining functions already defined in Maxima proper. -This is necessary in order to properly handle units. The user -should be aware that if other changes have been made to these functions by other -packages those changes will be overwritten by this loading process. - -The @emph{unit.mac} file also loads a lisp file @emph{unit-functions.lisp} which -contains the lisp functions needed for the package. - -@subsubsection Basic Usage - -By default, the @emph{unit} package does not use any derived dimensions, but will -convert all units to the seven fundamental dimensions using MKS units. -@example -(%i2) N; - kg m -(%o2) ---- - 2 - s -(%i3) dyn; - 1 kg m -(%o3) (------) (----) - 100000 2 - s -(%i4) g; - 1 -(%o4) (----) (kg) - 1000 -(%i5) centigram*inch/minutes^2; - 127 kg m -(%o5) (-------------) (----) - 1800000000000 2 - s -@end example -In some cases this is the desired behavior. If the user wishes to use other -units, this is achieved with the @code{setunits} command: -@example -(%i6) setunits([centigram,inch,minute]); -(%o6) done -(%i7) N; - 1800000000000 %in cg -(%o7) (-------------) (------) - 127 2 - %min -(%i8) dyn; - 18000000 %in cg -(%o8) (--------) (------) - 127 2 - %min -(%i9) g; -(%o9) (100) (cg) -(%i10) centigram*inch/minutes^2; - %in cg -(%o10) ------ - 2 - %min -@end example -The setting of units is quite flexible. For example, if we want to -get back to kilograms, meters, and seconds as defaults for those -dimensions we can do: -@example -(%i11) setunits([kg,m,s]); -(%o11) done -(%i12) centigram*inch/minutes^2; - 127 kg m -(%o12) (-------------) (----) - 1800000000000 2 - s -@end example -Or, alternately, if one wishes to restore the default behavior for -a particular dimension: -@example -(%i13) setunits([centigram,inch,minute]); -(%o13) done -(%i14) centigram*inch/minutes^2; - %in cg -(%o14) ------ - 2 - %min -(%i15) forget([cg,%in,%min]); -(%o15) [done, done, done] -(%i16) centigram*inch/minutes^2; - 127 kg m -(%o16) (-------------) (----) - 1800000000000 2 - s -@end example -Derived units are also handled by these commands: -@example -(%i17) setunits(N); -(%o17) done -(%i18) N; -(%o18) N -(%i19) dyn; - 1 -(%o19) (------) (N) - 100000 -(%i20) kg*m/s^2; -(%o20) N -(%i21) centigram*inch/minutes^2; - 127 -(%o21) (-------------) (N) - 1800000000000 -@end example -Notice that the @emph{unit} package recognized the non MKS combination -of mass, length, and inverse time squared as a force, and converted it -to Newtons. This is how Maxima works in general. If, for example, we -prefer dyne to Newtons, we simply do the following: -@example -(%i22) setunits(dyn); -(%o22) done -(%i23) kg*m/s^2; -(%o23) (100000) (dyn) -(%i24) centigram*inch/minutes^2; - 127 -(%o24) (--------) (dyn) - 18000000 -@end example -To discontinue simplifying to any force, we use the forget command: -@example -(%i26) forget(dyn); -(%o26) done -(%i27) kg*m/s^2; - kg m -(%o27) ---- - 2 - s -(%i28) centigram*inch/minutes^2; - 127 kg m -(%o28) (-------------) (----) - 1800000000000 2 - s -@end example -This would have worked equally well with @code{forget(N)} or -@code{forget(%force)}. @code{forget} operates on dimensions, -not units, so any unit of a particular dimension will work. The -dimension itself is also a legal argument. - -@subsubsection @code{convert} - -When resetting the global environment is overkill, there is the @code{convert} -command, which allows one time conversions. It can accept either a single -argument or a list of units to use in conversion. When a convert operation is -done, the normal global evaluation system is bypassed, in order to avoid the -desired result being converted again. As a consequence, for inexact calculations -"rat" warnings will be visible if the global environment controlling this behavior -(@code{ratprint}) is true. This is also useful for spot-checking the -accuracy of a global conversion. Another feature is @code{convert} will allow a -user to do Base Dimension conversions even if the global environment is set to -simplify to a Derived Dimension. - -@example -(%i2) kg*m/s^2; - kg m -(%o2) ---- - 2 - s -(%i3) convert(kg*m/s^2,[g,km,s]); - g km -(%o3) ---- - 2 - s -(%i4) convert(kg*m/s^2,[g,inch,minute]); - -`rat' replaced 39.37007874015748 by 5000//127 = 39.37007874015748 - 18000000000 %in g -(%o4) (-----------) (-----) - 127 2 - %min -(%i5) convert(kg*m/s^2,[N]); -(%o5) N -(%i6) convert(kg*m^2/s^2,[N]); -(%o6) m N -(%i7) setunits([N,J]); -(%o7) done -(%i8) convert(kg*m^2/s^2,[N]); -(%o8) m N -(%i9) convert(kg*m^2/s^2,[N,inch]); - -`rat' replaced 39.37007874015748 by 5000//127 = 39.37007874015748 - 5000 -(%o9) (----) (%in N) - 127 -(%i10) convert(kg*m^2/s^2,[J]); -(%o10) J -(%i11) kg*m^2/s^2; -(%o11) J -(%i12) setunits([g,inch,s]); -(%o12) done -(%i13) kg*m/s^2; -(%o13) N -(%i14) forget(N); -(%o14) false -(%i15) kg*m/s^2; - 5000000 %in g -(%o15) (-------) (-----) - 127 2 - s -(%i16) convert(kg*m/s^2,[g,inch,s]); - -`rat' replaced 39.37007874015748 by 5000//127 = 39.37007874015748 - 5000000 %in g -(%o16) (-------) (-----) - 127 2 - s -@end example - -TODO : dimension functionality, handling of temperature, -showabbr and friends. Show examples with addition of quantities containing -units. - -@subsubsection User defaults and resetting @emph{unit} behavior - -If a user wishes to have a default unit behavior other than that described, -they can make use of @emph{maxima-init.mac} and the @emph{usersetunits} -variable. The @emph{unit} package will check on startup to see if this variable -has been assigned a list. If it has, it will use setunits on that list and take -the units from that list to be defaults. @code{forget} will revert to the behavior -defined by usersetunits over its own defaults. For example, if we have a -@emph{maxima-init.mac} file containing: -@example -usersetunits : [N,J]; -@end example -we would see the following behavior: -@example -(%i1) load("./unit.mac"); -******************************************************************* -* Units version 0.50 * -* Definitions based on the NIST Reference on * -* Constants, Units, and Uncertainty * -* Conversion factors from various sources including * -* NIST and the GNU units package * -******************************************************************* - -Redefining necessary functions... -STYLE-WARNING: redefining TOPLEVEL-MACSYMA-EVAL in DEFUN -STYLE-WARNING: redefining MSETCHK in DEFUN -STYLE-WARNING: redefining KILL1 in DEFUN -STYLE-WARNING: redefining NFORMAT in DEFUN -Initializing unit arrays... -Done. -User defaults found... -User defaults initialized. -(%o1) ./unit.mac -(%i2) kg*m/s^2; -(%o2) N -(%i3) kg*m^2/s^2; -(%o3) J -(%i4) kg*m^3/s^2; -(%o4) J m -(%i5) kg*m*km/s^2; -(%o5) (1000) (J) -(%i6) setunits([dyn,eV]); -(%o6) done -(%i7) kg*m/s^2; -(%o7) (100000) (dyn) -(%i8) kg*m^2/s^2; -(%o8) (6241509596477042688) (eV) -(%i9) kg*m^3/s^2; -(%o9) (6241509596477042688) (eV m) -(%i10) kg*m*km/s^2; -(%o10) (6241509596477042688000) (eV) -(%i11) forget([dyn,eV]); -(%o11) [done, done] -(%i12) kg*m/s^2; -(%o12) N -(%i13) kg*m^2/s^2; -(%o13) J -(%i14) kg*m^3/s^2; -(%o14) J m -(%i15) kg*m*km/s^2; -(%o15) (1000) (J) -@end example -Without @code{usersetunits}, the initial inputs would have been converted -to MKS, and forget would have resulted in a return to MKS rules. Instead, -the user preferences are respected in both cases. Notice these can still -be overridden if desired. To completely eliminate this simplification - i.e. -to have the user defaults reset to factory defaults - the @code{dontusedimension} -command can be used. @code{forget} can restore user settings again, but -only if @code{usedimension} frees it for use. Alternately, -@code{kill(usersetunits)} will completely remove all knowledge of the user defaults -from the session. Here are some examples of how these various options work. -@example -(%i2) kg*m/s^2; -(%o2) N -(%i3) kg*m^2/s^2; -(%o3) J -(%i4) setunits([dyn,eV]); -(%o4) done -(%i5) kg*m/s^2; -(%o5) (100000) (dyn) -(%i6) kg*m^2/s^2; -(%o6) (6241509596477042688) (eV) -(%i7) forget([dyn,eV]); -(%o7) [done, done] -(%i8) kg*m/s^2; -(%o8) N -(%i9) kg*m^2/s^2; -(%o9) J -(%i10) dontusedimension(N); -(%o10) [%force] -(%i11) dontusedimension(J); -(%o11) [%energy, %force] -(%i12) kg*m/s^2; - kg m -(%o12) ---- - 2 - s -(%i13) kg*m^2/s^2; - 2 - kg m -(%o13) ----- - 2 - s -(%i14) setunits([dyn,eV]); -(%o14) done -(%i15) kg*m/s^2; - kg m -(%o15) ---- - 2 - s -(%i16) kg*m^2/s^2; - 2 - kg m -(%o16) ----- - 2 - s -(%i17) forget([dyn,eV]); -(%o17) [done, done] -(%i18) kg*m/s^2; - kg m -(%o18) ---- - 2 - s -(%i19) kg*m^2/s^2; - 2 - kg m -(%o19) ----- - 2 - s -(%i20) usedimension(N); -Done. To have Maxima simplify to this dimension, use setunits([unit]) -to select a unit. -(%o20) true -(%i21) usedimension(J); -Done. To have Maxima simplify to this dimension, use setunits([unit]) -to select a unit. -(%o21) true -(%i22) kg*m/s^2; - kg m -(%o22) ---- - 2 - s -(%i23) kg*m^2/s^2; - 2 - ... [truncated message content] |