This manual is for JACAL (version 2a1, August 2026), an interactive symbolic mathematics system.
Copyright © 1993-2000, 2002-2011, 2013, 2015, 2016, 2019, 2020, 2023-2026 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled “GNU Free Documentation License.”
JACAL is an interactive symbolic mathematics program. JACAL can manipulate and simplify equations, scalars, vectors, matrices, and tensors of (single and multiple valued) algebraic expressions containing numbers, variables, radicals, and algebraic and transcendental functions.
JACAL 2a1 was released August 2026. Current information about JACAL can be found on JACAL’s WWW home page:
JACAL, part of the GNU project, is free software, and you are welcome
to redistribute it under certain conditions; See the file COPYING with
this program or type (terms)(); to JACAL for details.
For a list of the features that have changed since the last JACAL release, see the file ANNOUNCE. For a list of the features that have changed over time, see the file ChangeLog.
Polynomial Factoring.
Tensors.
Most of JACAL
The maintainer can be reached as ‘agj@alum.mit.edu’.
In December of 1987, in order to facilitate the design of constant impedance electrical filters (diplexers), I (Aubrey Jaffer) wrote a symbolic circuit analysis program. It was written in LISP and implemented canonical rational expressions (ratio of multivariate polynomials) as its representation of the (small signal) Laplace Transform of currents, voltages, and impedances. After doing some reading about symbolic manipulation, I became fascinated with the problem of canonical forms. That interest produced JACAL, an interactive symbolic mathematics program similar to Maxima.
I initially used JACAL for electronics modeling, handling equations complicated enough that error-free pencil and paper manipulations were difficult. As JACAL’s capabilities grew, more applications were found.
Around 1993-1995 Mike Thomas added univariate and multivariate polynomial factorization. In 1993-1997, Jerry D. Hedden added tensor manipulations to JACAL.
Having retired, in 2024 I finally implemented indefinite integration (actually anti-differentiation) of rational functions incorporating radicals.
Spurred by my mathematical physics work in fluid-mechanics, I
implemented logarithms, exponentials, Lambert-W (the inverse of
x*exp(x)), and trigonometric functions as the solutions to
ordinary differential equations (ODE).
Daniel Richardson.
Some undecidable problems involving elementary functions of a real variable.
The Journal of Symbolic Logic, 33(4):514–520, 1968.
B. F. Caviness.
On canonical forms and simplification.
J. ACM, 17(2):385–396, April 1970.
Paul S. Wang.
The undecidability of the existence of zeros of real elementary functions.
J. ACM, 21(4):586589, October 1974.
J.F. Ritt.
Differential Algebra. American Mathematical Society: Colloquium publications.
Dover Publications, 1966.
David Cox.
Ideals, Varieties, and Algorithms An Introduction to Computational Algebraic Geometry and Commutative Algebra.
Undergraduate Texts in Mathematics.
Springer New York, New York, NY, 2nd ed. 1997. edition, 1997.
B. F. Caviness and R. J. Fateman.
Simplification of radical expressions.
In Proceedings of the Third ACM Symposium on Symbolic and Algebraic Computation, SYMSAC ’76
pages 329–338, New York, NY, USA, 1976. ACM.
Donald Ervin Knuth.
The Art of Computer Programming : Seminumerical Algorithms (Vol 2).
2nd Ed (1981) Addison-Wesley Pub Co; ISBN: 0-201-03822-6
Keith O. Geddes, Stephen R. Czapor, George Labahn.
Algorithms for Computer Algebra.
(October 1992) Kluwer Academic Pub; ISBN: 0-7923-9259-0
Y. Siret (Editor), E. Tournier, J. H. Davenport, F. Tournier.
Computer Algebra: Systems and Algorithms for Algebraic Computation
2nd edition (June 1993) Academic Press; ISBN: 0-122-04232-8
Richard Kelsey and William Clinger and Jonathan (Rees, editors)
Revised(5) Report on the Algorithmic Language Scheme,
Higher-Order and Symbolic Computation Volume 11, Number 1 (1998),
pp. 7-105, or
ACM SIGPLAN Notices 33(9), September 1998.
Todd R. Eigenschink and Aubrey Jaffer.
SLIB; The Portable Scheme Library
The JACAL program is written in the Algorithmic Language Scheme. So you must have or install a Scheme implementation in order to run it. JACAL also requires the SLIB Portable Scheme library which is available from https://www.gnu.org/software/slib. The installation procedures given here provide the SCM Scheme implementation along with SLIB and JACAL. If your system has a Scheme (or Guile) implementation installed, then the ‘scm’ steps are unnecessary.
If you lack permission to install into /usr/local/, you can install
into your home directory by changing /usr/local/ to your home
directory in this script.
wget https://ftp.gnu.org/gnu/scm/scm-5f5.tar.gz wget https://ftp.gnu.org/gnu/slib/slib-3c2.tar.gz wget https://ftp.gnu.org/gnu/jacal/jacal-2a1.tar.gz tar -xzf scm-5f5.tar.gz tar -xzf slib-3c2.tar.gz tar -xzf jacal-2a1.tar.gz (cd slib-3c2; ./configure --prefix=/usr/local/; make install) (cd scm-5f5; ./configure --prefix=/usr/local/; make scm; make install) (cd jacal-2a1; ./configure --prefix=/usr/local/; make install) # rm scm-5f5.tar.gz slib-3c2.tar.gz jacal-2a1.tar.gz
The command ‘jacal’ will start an interactive session.
wget http://groups.csail.mit.edu/mac/ftpdir/scm/scm-5f5-1.x86_64.rpm wget http://groups.csail.mit.edu/mac/ftpdir/scm/slib-3c2-1.noarch.rpm wget http://groups.csail.mit.edu/mac/ftpdir/scm/jacal-2a1-1.noarch.rpm rpm -U scm-5f5-1.x86_64.rpm slib-3c2-1.noarch.rpm jacal-2a1-1.noarch.rpm # rm scm-5f5-1.x86_64.rpm slib-3c2-1.noarch.rpm jacal-2a1-1.noarch.rpm
The command ‘jacal’ will start an interactive session using ELK, Gambit, Gauche, Guile, Larceny, MIT-Scheme, MzScheme, Scheme48, SCM, or SISC. Type ‘jacal --help’ for instructions.
Download and run
http://groups.csail.mit.edu/mac/ftpdir/scm/slib-3c2-1.exe,
http://groups.csail.mit.edu/mac/ftpdir/scm/scm-5f4-1.exe, and
http://groups.csail.mit.edu/mac/ftpdir/scm/jacal-2a1-1.exe.
details the LACK OF WARRANTY for Jacal and the conditions for distributing Jacal.
is a short introduction to using Jacal.
documents changes to Jacal.
is a unix (sh) script to start an interactive jacal session.
is a batch file of Robertson-Walker model of General Relativity. "batch(rw.math);" to execute its commands in Jacal.
is a batch file which tests Jacal.
is documentation on how to use jacal in TeXinfo format.
has files telling about how jacal works.
gives an algorithm for clearing radicals and other algebraic field extensions from denominators.
explains how to create new grammars.
explains mid-level data formats. From a Dr. Dobbs article.
article explaining jacal’s integration algorithm and transcendental function simplification.
is the file you load into scheme in order to run jacal.
contains comments describing the rest of the files.
has initializations for modes in Jacal.
Copyright © 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc. http://fsf.org/ Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
The purpose of this License is to make a manual, textbook, or other functional and useful document free in the sense of freedom: to assure everyone the effective freedom to copy and redistribute it, with or without modifying it, either commercially or noncommercially. Secondarily, this License preserves for the author and publisher a way to get credit for their work, while not being considered responsible for modifications made by others.
This License is a kind of “copyleft”, which means that derivative works of the document must themselves be free in the same sense. It complements the GNU General Public License, which is a copyleft license designed for free software.
We have designed this License in order to use it for manuals for free software, because free software needs free documentation: a free program should come with manuals providing the same freedoms that the software does. But this License is not limited to software manuals; it can be used for any textual work, regardless of subject matter or whether it is published as a printed book. We recommend this License principally for works whose purpose is instruction or reference.
This License applies to any manual or other work, in any medium, that contains a notice placed by the copyright holder saying it can be distributed under the terms of this License. Such a notice grants a world-wide, royalty-free license, unlimited in duration, to use that work under the conditions stated herein. The “Document”, below, refers to any such manual or work. Any member of the public is a licensee, and is addressed as “you”. You accept the license if you copy, modify or distribute the work in a way requiring permission under copyright law.
A “Modified Version” of the Document means any work containing the Document or a portion of it, either copied verbatim, or with modifications and/or translated into another language.
A “Secondary Section” is a named appendix or a front-matter section of the Document that deals exclusively with the relationship of the publishers or authors of the Document to the Document’s overall subject (or to related matters) and contains nothing that could fall directly within that overall subject. (Thus, if the Document is in part a textbook of mathematics, a Secondary Section may not explain any mathematics.) The relationship could be a matter of historical connection with the subject or with related matters, or of legal, commercial, philosophical, ethical or political position regarding them.
The “Invariant Sections” are certain Secondary Sections whose titles are designated, as being those of Invariant Sections, in the notice that says that the Document is released under this License. If a section does not fit the above definition of Secondary then it is not allowed to be designated as Invariant. The Document may contain zero Invariant Sections. If the Document does not identify any Invariant Sections then there are none.
The “Cover Texts” are certain short passages of text that are listed, as Front-Cover Texts or Back-Cover Texts, in the notice that says that the Document is released under this License. A Front-Cover Text may be at most 5 words, and a Back-Cover Text may be at most 25 words.
A “Transparent” copy of the Document means a machine-readable copy, represented in a format whose specification is available to the general public, that is suitable for revising the document straightforwardly with generic text editors or (for images composed of pixels) generic paint programs or (for drawings) some widely available drawing editor, and that is suitable for input to text formatters or for automatic translation to a variety of formats suitable for input to text formatters. A copy made in an otherwise Transparent file format whose markup, or absence of markup, has been arranged to thwart or discourage subsequent modification by readers is not Transparent. An image format is not Transparent if used for any substantial amount of text. A copy that is not “Transparent” is called “Opaque”.
Examples of suitable formats for Transparent copies include plain ASCII without markup, Texinfo input format, LaTeX input format, SGML or XML using a publicly available DTD, and standard-conforming simple HTML, PostScript or PDF designed for human modification. Examples of transparent image formats include PNG, XCF and JPG. Opaque formats include proprietary formats that can be read and edited only by proprietary word processors, SGML or XML for which the DTD and/or processing tools are not generally available, and the machine-generated HTML, PostScript or PDF produced by some word processors for output purposes only.
The “Title Page” means, for a printed book, the title page itself, plus such following pages as are needed to hold, legibly, the material this License requires to appear in the title page. For works in formats which do not have any title page as such, “Title Page” means the text near the most prominent appearance of the work’s title, preceding the beginning of the body of the text.
The “publisher” means any person or entity that distributes copies of the Document to the public.
A section “Entitled XYZ” means a named subunit of the Document whose title either is precisely XYZ or contains XYZ in parentheses following text that translates XYZ in another language. (Here XYZ stands for a specific section name mentioned below, such as “Acknowledgements”, “Dedications”, “Endorsements”, or “History”.) To “Preserve the Title” of such a section when you modify the Document means that it remains a section “Entitled XYZ” according to this definition.
The Document may include Warranty Disclaimers next to the notice which states that this License applies to the Document. These Warranty Disclaimers are considered to be included by reference in this License, but only as regards disclaiming warranties: any other implication that these Warranty Disclaimers may have is void and has no effect on the meaning of this License.
You may copy and distribute the Document in any medium, either commercially or noncommercially, provided that this License, the copyright notices, and the license notice saying this License applies to the Document are reproduced in all copies, and that you add no other conditions whatsoever to those of this License. You may not use technical measures to obstruct or control the reading or further copying of the copies you make or distribute. However, you may accept compensation in exchange for copies. If you distribute a large enough number of copies you must also follow the conditions in section 3.
You may also lend copies, under the same conditions stated above, and you may publicly display copies.
If you publish printed copies (or copies in media that commonly have printed covers) of the Document, numbering more than 100, and the Document’s license notice requires Cover Texts, you must enclose the copies in covers that carry, clearly and legibly, all these Cover Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on the back cover. Both covers must also clearly and legibly identify you as the publisher of these copies. The front cover must present the full title with all words of the title equally prominent and visible. You may add other material on the covers in addition. Copying with changes limited to the covers, as long as they preserve the title of the Document and satisfy these conditions, can be treated as verbatim copying in other respects.
If the required texts for either cover are too voluminous to fit legibly, you should put the first ones listed (as many as fit reasonably) on the actual cover, and continue the rest onto adjacent pages.
If you publish or distribute Opaque copies of the Document numbering more than 100, you must either include a machine-readable Transparent copy along with each Opaque copy, or state in or with each Opaque copy a computer-network location from which the general network-using public has access to download using public-standard network protocols a complete Transparent copy of the Document, free of added material. If you use the latter option, you must take reasonably prudent steps, when you begin distribution of Opaque copies in quantity, to ensure that this Transparent copy will remain thus accessible at the stated location until at least one year after the last time you distribute an Opaque copy (directly or through your agents or retailers) of that edition to the public.
It is requested, but not required, that you contact the authors of the Document well before redistributing any large number of copies, to give them a chance to provide you with an updated version of the Document.
You may copy and distribute a Modified Version of the Document under the conditions of sections 2 and 3 above, provided that you release the Modified Version under precisely this License, with the Modified Version filling the role of the Document, thus licensing distribution and modification of the Modified Version to whoever possesses a copy of it. In addition, you must do these things in the Modified Version:
If the Modified Version includes new front-matter sections or appendices that qualify as Secondary Sections and contain no material copied from the Document, you may at your option designate some or all of these sections as invariant. To do this, add their titles to the list of Invariant Sections in the Modified Version’s license notice. These titles must be distinct from any other section titles.
You may add a section Entitled “Endorsements”, provided it contains nothing but endorsements of your Modified Version by various parties—for example, statements of peer review or that the text has been approved by an organization as the authoritative definition of a standard.
You may add a passage of up to five words as a Front-Cover Text, and a passage of up to 25 words as a Back-Cover Text, to the end of the list of Cover Texts in the Modified Version. Only one passage of Front-Cover Text and one of Back-Cover Text may be added by (or through arrangements made by) any one entity. If the Document already includes a cover text for the same cover, previously added by you or by arrangement made by the same entity you are acting on behalf of, you may not add another; but you may replace the old one, on explicit permission from the previous publisher that added the old one.
The author(s) and publisher(s) of the Document do not by this License give permission to use their names for publicity for or to assert or imply endorsement of any Modified Version.
You may combine the Document with other documents released under this License, under the terms defined in section 4 above for modified versions, provided that you include in the combination all of the Invariant Sections of all of the original documents, unmodified, and list them all as Invariant Sections of your combined work in its license notice, and that you preserve all their Warranty Disclaimers.
The combined work need only contain one copy of this License, and multiple identical Invariant Sections may be replaced with a single copy. If there are multiple Invariant Sections with the same name but different contents, make the title of each such section unique by adding at the end of it, in parentheses, the name of the original author or publisher of that section if known, or else a unique number. Make the same adjustment to the section titles in the list of Invariant Sections in the license notice of the combined work.
In the combination, you must combine any sections Entitled “History” in the various original documents, forming one section Entitled “History”; likewise combine any sections Entitled “Acknowledgements”, and any sections Entitled “Dedications”. You must delete all sections Entitled “Endorsements.”
You may make a collection consisting of the Document and other documents released under this License, and replace the individual copies of this License in the various documents with a single copy that is included in the collection, provided that you follow the rules of this License for verbatim copying of each of the documents in all other respects.
You may extract a single document from such a collection, and distribute it individually under this License, provided you insert a copy of this License into the extracted document, and follow this License in all other respects regarding verbatim copying of that document.
A compilation of the Document or its derivatives with other separate and independent documents or works, in or on a volume of a storage or distribution medium, is called an “aggregate” if the copyright resulting from the compilation is not used to limit the legal rights of the compilation’s users beyond what the individual works permit. When the Document is included in an aggregate, this License does not apply to the other works in the aggregate which are not themselves derivative works of the Document.
If the Cover Text requirement of section 3 is applicable to these copies of the Document, then if the Document is less than one half of the entire aggregate, the Document’s Cover Texts may be placed on covers that bracket the Document within the aggregate, or the electronic equivalent of covers if the Document is in electronic form. Otherwise they must appear on printed covers that bracket the whole aggregate.
Translation is considered a kind of modification, so you may distribute translations of the Document under the terms of section 4. Replacing Invariant Sections with translations requires special permission from their copyright holders, but you may include translations of some or all Invariant Sections in addition to the original versions of these Invariant Sections. You may include a translation of this License, and all the license notices in the Document, and any Warranty Disclaimers, provided that you also include the original English version of this License and the original versions of those notices and disclaimers. In case of a disagreement between the translation and the original version of this License or a notice or disclaimer, the original version will prevail.
If a section in the Document is Entitled “Acknowledgements”, “Dedications”, or “History”, the requirement (section 4) to Preserve its Title (section 1) will typically require changing the actual title.
You may not copy, modify, sublicense, or distribute the Document except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, or distribute it is void, and will automatically terminate your rights under this License.
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, receipt of a copy of some or all of the same material does not give you any rights to use it.
The Free Software Foundation may publish new, revised versions of the GNU Free Documentation License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. See http://www.gnu.org/copyleft/.
Each version of the License is given a distinguishing version number. If the Document specifies that a particular numbered version of this License “or any later version” applies to it, you have the option of following the terms and conditions either of that specified version or of any later version that has been published (not as a draft) by the Free Software Foundation. If the Document does not specify a version number of this License, you may choose any version ever published (not as a draft) by the Free Software Foundation. If the Document specifies that a proxy can decide which future versions of this License can be used, that proxy’s public statement of acceptance of a version permanently authorizes you to choose that version for the Document.
“Massive Multiauthor Collaboration Site” (or “MMC Site”) means any World Wide Web server that publishes copyrightable works and also provides prominent facilities for anybody to edit those works. A public wiki that anybody can edit is an example of such a server. A “Massive Multiauthor Collaboration” (or “MMC”) contained in the site means any set of copyrightable works thus published on the MMC site.
“CC-BY-SA” means the Creative Commons Attribution-Share Alike 3.0 license published by Creative Commons Corporation, a not-for-profit corporation with a principal place of business in San Francisco, California, as well as future copyleft versions of that license published by that same organization.
“Incorporate” means to publish or republish a Document, in whole or in part, as part of another Document.
An MMC is “eligible for relicensing” if it is licensed under this License, and if all works that were first published under this License somewhere other than this MMC, and subsequently incorporated in whole or in part into the MMC, (1) had no cover texts or invariant sections, and (2) were thus incorporated prior to November 1, 2008.
The operator of an MMC Site may republish an MMC contained in the site under CC-BY-SA on the same site at any time before August 1, 2009, provided the MMC is eligible for relicensing.
To use this License in a document you have written, include a copy of the License in the document and put the following copyright and license notices just after the title page:
Copyright (C) year your name. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled ``GNU Free Documentation License''.
If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, replace the “with…Texts.” line with this:
with the Invariant Sections being list their titles, with
the Front-Cover Texts being list, and with the Back-Cover Texts
being list.
If you have Invariant Sections without Cover Texts, or some other combination of the three, merge those two alternatives to suit the situation.
If your document contains nontrivial examples of program code, we recommend releasing these examples in parallel under your choice of free software license, such as the GNU General Public License, to permit their use in free software.
If you successfully executed one of the installations of the previous section, then typing ‘jacal’ or clicking an icon will begin an interactive session.
To manually start jacal, start your Scheme implementation with SLIB. This may involve setting up that implementation’s initialization file or LOADing a ‘.init’ file from the slib directory. Then type:
(slib:load "/usr/local/lib/jacal/math")
where /usr/local/lib/jacal/ is a path to the JACAL directory. JACAL should then print:
JACAL version 2a1, Copyright 1989-2026 Aubrey Jaffer JACAL comes with ABSOLUTELY NO WARRANTY; for details type `(terms)'. This is free software, and you are welcome to redistribute it under certain conditions; type `(terms)' for details. ;;; Type (math); to begin from Scheme session.
Do as it says:
(math) ⇒ type qed; to return to scheme, type help; for help. (%0000)
And you are ready to try the commands described in the rest of the manual.
JACAL tries to catch any errors it encounters and print an informative message before returning to the prompt. If there are unmatched parentheses or missing delimiters in your typed command, type the closing delimiters, digits for “expression missing”, and semicolon (followed by newline) until it returns to the prompt:
(%0000) ({adf;
^ "mismatched delimiter" #\; expecting #\}
;
^ "mismatched delimiter" #\; expecting #\)
;
%0000: adf
(%0001)
If that is unsuccessful, typing ‘CTRL-C’ will likely return you to the underlying Scheme session.
As JACAL is a complicated program there are bugs which will occasionally
cause the program to stop with some sort of error reported by the
underlying Scheme system. In interactive implementations (such as SCM)
you can usually continue your session by typing (math). The
expression which was input to JACAL just before the error will be lost
but you should be able to otherwise continue with your session.
If you define identifiers which have already been used in formulas, the earlier uses are not updated. You can restore a name to its unassigned status by defining it to itself:
(%0001) a: 5/7;
a: 5/7
(%0001) a+3;
26
%0001: --
7
(%0002) a:a;
a: a
(%0002) a+3;
%0002: 3 + a
If the underlying scheme implementation supports a (restart)
command, then typing restart(); in JACAL will re-initiate the
session, forgetting all the commands and formulas you entered
previously:
(%0003) restart(); .............. JACAL version 2a1, Copyright 1989-2026 Aubrey Jaffer JACAL comes with ABSOLUTELY NO WARRANTY; for details type `(terms)'. This is free software, and you are welcome to redistribute it under certain conditions; type `(terms)' for details. ;;; Type (math); to begin from Scheme session. Type qed; to return to Scheme, type help; for help. (%0000)
The command quit(); will end your JACAL session.
With non-interactive Scheme implementations the JACAL command
qed; or typing the end-of-file character (C-z on MS-DOS
and VMS, C-d on others) will end your JACAL session.
The command qed; will return to the interactive Scheme session.
Typing (math) will return to the JACAL session.
From the interactive Scheme session (exit) or possibly an
end-of-file character will terminate the session.
The canonical aspect of JACAL is that all equations and expressions involving variables undergo nomalization such that two formulas which are equivalent have the same representation. This representation is affected by variable ordering; substituting one variable name for another looks different but expresses the same mathematical constraint.
As with all symbolic algebra systems, roots of unity (1) are not uniquely normalizable. JACAL’s guarantees apply only to expressions involving variables.
JACAL prioritizes simplicity of expressions over full canonical reductions. For instance, all trigonometric functions can be expressed as (complex number) exponentials and logarithms; but it is difficult to understand that representation. Instead, trigonometric expressions are represented in terms of tangent (tan) and arctangent (atan).
A transcendental function composed with its inverse cancels each other
if the argument to the inverse function involves at least one
variable. exp(integer*log(argument)) reduces to
argument^(integer) if argument involves at
least one variable. exp(log(argument)/integer)
does not reduce if integer is greater than one. The ^
function reduces this case to a radical:
(%0000) %expt(a+x,1/5);
log(a + x)
%0000: exp(----------)
5
(%0001) (a+x)^(1/5);
1/5
%0001: (a + x)
Trignometric functions have similar reductions:
(%0002) sin(asin(x));
%0002: x
(%0003) asin(sin(x));
%0003: x
(%0004) sin(3*asin(x));
3
%0004: - 3 x + 4 x
(%0005) tan(3*atan(x));
3
- 3 x + x
%0005: ----------
2
-1 + 3 x
(%0006) atan(3*tan(x));
%0006: atan(3 tan(x))
(%0007) tan(6*atan(x));
3 5
6 x - 20 x + 6 x
%0007: ----------------------
2 4 6
1 - 15 x + 15 x - x
The Lambert-W function (%W) is the inverse of
z*exp(z). Currently the reduction works in one
direction; the other will eventually be supported:
(%0008) %W(x*exp(x)); %0008: x (%0009) %W(x)*exp(%W(x)); %0009: %W(x) exp(%W(x))
Because transcendental functions are defined by their differential equations, JACAL can produce their derivatives:
(%0015) diff(%W(x),x);
%W(x)
%0015: -----------
x + x %W(x)
(%0016) diff(tan(x),x);
2
%0016: 1 + (tan(x))
(%0017) diff(sin(x),x);
1
%0017: ------------------
2 1/2
(1 + (tan(x)) )
(%0018) diff(cos(x),x);
tan(x)
%0018: --------------------
2 1/2
- (1 + (tan(x)) )
(%0019) diff(%expt(x,1/5),x);
log(x)
exp(------)
5
%0019: -----------
5 x
(%0020) diff(x^(1/5),x);
1
%0020: ------
4/5
5 x
The usual algebraic reductions also work:
(%0024) sin(x/a)^2+cos(x/a)^2; %0024: 1
JACAL provides some functions which it does not canonicalize:
imagpart, realpart, abs, and cabs.
JACAL-2a1 is a major release incorporating transcendental functions.
Do not raise transcendental functions to powers like sin^2(x).
Instead, use sin(x)^2.
Trigonometric sum and difference of angle formulas do not reduce.
Things that are labeled as Operators can occur in expressions output by
Jacal. Things that are labeled as Commands act upon their arguments and
do not generally occur in expressions output by Jacal. Things that are
labeled as flags are set to control aspects of the Jacal
environment.
The examples throughout this text were produced using the SCM Scheme implementation.
Jacal has several input grammars it understands. The standard
input grammar (which is the same as the std and disp2d
input grammars) is used in this manual. It is very similar to
Maxima input grammar and the Algol family of computer
languages.
Identifier names are case sensitive.
Addition of scalar quantities or componentwise addition of bunches is
accomplished by means of the infix operator +. For example,
(%0000) a:[[1, 3, 5], [2, 4, 7]];
[ 1 3 5 ]
a: [ ]
[ 2 4 7 ]
(%0000) b:[2, 4];
b: [2, 4]
(%0000) a + b;
[ 3 5 7 ]
%0000: [ ]
[ 6 8 11 ]
(%0001) 3 + 2;
%0001: 5
(%0002) c + b;
%0002: [2 + c, 4 + c]
The symbol - is used to denote either the binary infix operator
subtraction or the unary minus.
(%0004) -[1,2,3]; %0004: [-1, -2, -3] (%0005) 3-7; %0005: -4
Jacal allows the use of +/- and -/+ as ambiguous signs
(unary plus-or-minus, unary minus-or-plus) and as ambiguous infix
operators (binary plus-or-minus, binary minus-or-plus). The value
+/- is also represented by the constant %sqrt1, while
-/+ is represented by -%sqrt1.
(%0006) u:+/-3; u: 3 %sqrt1 (%0006) u^2; %0006: 9 (%0007) +/-(u); %0007: 3 (%0008) u-/+3; %0008: 0
Multiplication of scalar expressions such as numbers, polynomials,
rational functions and algebraic functions is denoted by the infix
operator *. For example,
(%0000) (2 + 3 * a) * 4 * a * b^2;
2 2
%0000: (8 a + 12 a ) b
One can also use * as an infix operator on bunches. In that
case, it operates componentwise, in an appropriate sense. If the
bunches are square matrices, the operator * multiplies
corresponding entries of the two factors. It does not perform matrix
multiplication. To multiply matrices one instead uses the operator
. (i.e., a period). More generally, any binary scalar operator
other than ^ can be used on bunches and acts
componentwise.
The symbol for division in Jacal is /. For example, the value
returned by 6 / 2 is 3.
(%0001) (x^2 - y^2) / (x - y); %0001: x + y
Note: using divide to divide a polynomial by an integer does not work.
The infix operator ^ is used for exponentiation of scalar
quantitites or for componentwise exponentiation of bunches. For
example, 2^5 returns 32. Unlike the other scalar infix
operators, one cannot use ^ for component-wise operations on
bunches. Furthermore, one should not try to use ^ to raise a
square matrix to a power. Instead, one should use ^^.
(%0002) (1+x)^4;
2 3 4
%0002: 1 + 4 x + 6 x + 4 x + x
In Jacal, the equals sign = is not used for conditionals
and it is not used for assignments. To assign a value to an
identifier, use either : or :=. The operator =
merely returns a value of the form 0 = expression. The
value returned by a = b, for example is 0 = a - b.
(%0003) 1=2; ;;; eliminate singular-reduction [-1]
The infix operator || is from electrical engineering and
represents the effective impedance of the parallel connection of
components of impedances Z1 and Z2:
(%0003) Z1 || Z2;
Z1 Z2
%0003: -------
Z1 + Z2
Here eqn_i is an equation for i = 1 … n and where
var_j is a variable for j = 1 … m.
eliminate returns a list of equations obtained by eliminating the
variables var_1, …, var_m from the equations
eqn_1, …, eqn_n.
(%0004) eliminate([x^2+y=0,x^3+y=0],[x]);
2
%0004: 0 = y + y
(%0005) eliminate([x+y+z=3,x^2+y^2+z^2=3,x^3+y^3+z^3=3],[x,y]);
%0005: 0 = -1 + z
The equation eqn must contain an occurrence of variable var.
suchthat returns an expression for all complex values of
var satisfying eqn. suchthat is useful for
extracting an expression from an equation.
(%0000) a*x+b*y+c = 0;
%0000: 0 = c + a x + b y
(%0001) suchthat(x,%0000);
- c - b y
%0001: ---------
a
If an expression rather than an equation is given to suchthat, it
is as though the equation exp=0 was given.
(%0002) suchthat(x, a*x+b*y+c);
- c - b y
%0002: ---------
a
An alternative infix notation is also available for suchthat.
When used in combination with the ‘{ }’ notation for or,
the set notation used by some textbooks results.
If var in eqn has multiple roots, a named
ring extension will be introduced to represent any one of those
roots. When multiple values are returned, the result (in disp2d
and standard grammars) is wrapped with ‘{ }’.
(%0003) x | a*x^2 + b*x + c;
2
%ext1: c + b %ext1 + a %ext1
(%0003) %ext1^2;
- c - b %ext1
%0003: -------------
a
Returns the rule or expression defining symbol.
(%0000) {x | a*x^2 + b*x + c};
2
%ext1: c + b %ext1 + a %ext1
(%0000) definition(%ext1);
2
%0000: 0 = c + b %ext1 + a %ext1
(%0001) definition(sqrt);
2/2
%0001: 0 = - @1 + @1
(%0002) definition(sqrt(x));
2/2
%0002: 0 = - x + x
(%0003) definition(tan);
2
%0003: 0 = - @1' + (1 + @1 ) @2'
(%0004) definition(tan(x));
2
%0004: 0 = - (tan(x))' + (1 + (tan(x)) ) x'
(%0005) definition(%tanP);
%0005: %tanP + @2 %tanQ
[-1 + @1] [-1 + @1]
(%0006) definition(%tanPQ);
%tanP
[@1]
%0006: ---------
%tanQ
[@1]
The function or takes as inputs one or more equations or
values. If the inputs are equations, then or returns an equation
which is equivalent to the assertion that at least one of the input
equations holds. If the inputs to or are values instead of two
equations, then the function or returns a multiple value. If the
inputs to or consist of both equations and values, then or
will return the multiple values.
(%0000) or(x=2,y=3);
%0000: 0 = 6 - 3 x + (-2 + x) y
(%0001) or(2,3);
2
%0001: {@ | 0 = 6 - 5 @ + @ }
(%0002) or(2,3)^2;
2
%0002: {@ | 0 = 36 - 13 @ + @ }
(%0003) factor %0001;
%0003: 3 2
(%0004) factor %0002;
%0004: 9 4
(%0005) or(x=2,17);
%0005: 17
‘{eqn, … }’ can be used as an alternate syntax for
or:
(%0012) : {+1, -1};
2
%0012: {:@ | 0 = -1 + :@ }
The function num takes a rational expression as input and
returns a numerator of the expression.
(%0013) num((x^2+y^2)/(x^2-y^2));
2 2
%0013: - x - y
(%0014) num(7/4);
%0014: 7
(%0015) num(7/(4/3));
%0015: 21
The Jacal command denom is used to obtain the denominator of a
rational expression.
(%0016) denom(4/5);
%0016: 5
(%0017) denom((x^2+y^2)/(x^2-y^2));
2 2
%0017: - x + y
The command listofvars takes as input a rational expression and
returns a list of the variables that occur in that expression.
(%0018) listofvars(x^2+y^3); %0018: [x, y] (%0019) listofvars((x^2+y^3)/(2*x^7+y*x+z)); %0019: [x, y, z]
Returns the coefficient of %i in expression z;
Returns all but the coefficient of %i in expression z;
| z |
Returns the square root of the sum of the squares of the realpart
and the imagpart of z.
(%0020) abs(z); %0020: |z| (%0021) abs(-z); %0021: |- z| (%0022) abs(-3); %0022: 3 (%0023) abs(1/%i); %0023: 1 (%0024) realpart(1/%i); %0024: 0 (%0025) imagpart(1/%i); %0025: -1 (%0026) imagpart(3/%i); %0026: -3
Returns the degree of polynomial or equation poly in variable var.
Returns the total-degree, the degree of its highest degree monomial, of polynomial or equation poly.
(%0028) degree(a*x*x + b*y*x + c*y*y + d*x + e*y + f, y); %0028: 2 (%0029) degree(a*x*x + b*y*x + c*y*y + d*x + e*y + f); %0029: 3
Note that all roots and radicals count as degree 1.
The command coeff is used to determine the coefficient of a
certain power of a variable in a given polynomial. Here poly is a
polynomial and var is a variable. If the optional third argument
is omitted, then Jacal returns the coefficient of the variable var
in poly. Otherwise it returns the coefficient of var^deg in
poly. The function coeffs returns a list of all of the
coefficients. For example,
(%0009) coeff((x + 2)^4, x, 3);
%0009: 8
(%0010) (x + 2)^4;
2 3 4
%0010: 16 + 32 x + 24 x + 8 x + x
(%0011) coeff((x + 2)^4, x);
%0011: 32
(%0012) coeffs((x + 2)^4, x);
%0012: [16, 32, 24, 8, 1]
The function poly provides an inverse to the function
coeffs, allowing one to recover a polynomial from its vector or
list of coefficients.
(%0013) poly(y, [16, 32, 24, 8, 1]);
2 3 4
%0013: 16 + 32 y + 24 y + 8 y + y
(%0014) poly(y, 16, 32, 24, 8, 1);
2 3 4
%0014: 16 + 32 y + 24 y + 8 y + y
The function poly returns the expression equal to 0 in equation
eqn. Be aware that the sign and scaling of the returned
polynomial will not necessarily match those in the equation creating
eqn.
(%0015) 2*a = 4*c; %0015: 0 = - a + 2 c (%0016) poly(%0015); %0016: - a + 2 c
Returns a list of content and primitive part of a polynomial with respect to the variable. The content is the GCD of the coefficients of the polynomial in the variable. The primitive part is poly divided by the content.
content(2*x*y+4*x^2*y^2,y);
2
%0017: [2 x, y + 2 x y ]
The command divide treats divident and divisor as
polynomials in the variable var and returns a pair
‘[quotient, remainder]’ such that dividend
= divisor * quotient + remainder. If the third
argument var is omitted Jacal will choose a variable on its own
with respect to which it will do the division. In particular, of
dividend and divisor are both numerical, one can safely omit
the third argument.
(%0018) divide(x^2+y^2,x-7*y^2,x);
2 2 4
%0018: [x + 7 y , y + 49 y ]
(%0019) divide(-7,3);
%0019: [-2, -1]
(%0020) divide(x^2+y^2+z^2,x+y+z);
2 2
%0020: [- x - y + z, 2 x + 2 x y + 2 y ]
(%0021) divide(x^2+y^2+z^2,x+y+z,y);
2 2
%0021: [- x + y - z, 2 x + 2 x z + 2 z ]
(%0022) divide(x^2+y^2+z^2,x+y+z,z);
2 2
%0022: [- x - y + z, 2 x + 2 x y + 2 y ]
Returns poly1 reduced with respect to poly2 (or eqn) and var. If poly2 is univariate, the third argument is not needed.
Returns poly1 with all the coefficients taken modulo n.
Returns poly1 with all the coefficients taken modulo the current modulus.
If the modulus (n or the current modulus) is negative, then the results use symmetric representation.
(%0023) x^4+4 mod 3;
4
%0023: 1 + x
(%0024) x^4+4 mod x^2=2;
%0024: 8
(%0025) mod(x^3*a*7+x*8+34, -3);
3
%0025: 1 - x + a x
(%0026) mod(5,2);
%0026: 1
(%0027) mod(x^4+4,x^2=2,x);
%0027: 8
The Jacal function gcd takes as arguments two polynomials with
integer coefficients and returns a greatest common divisor of the two
polynomials. This includes the case where the polynomials are
integers.
(%0028) gcd(x^4-y^4,x^6+y^6);
2 2
%0028: x + y
(%0029) gcd(4,10);
%0029: 2
Here poly is a polynomial and var is a variable. This function returns the square of the product of the differences of the roots of the polynomial poly with respect to the variable var.
(%0030) discriminant(x^3 - 1, x); %0030: -27
The function resultant returns the resultant of the polynomials
poly_1 and poly_2 with respect to the variable
var.
(%0031) resultant(x^2 + a, x^3 + a, x);
2 3
%0031: a + a
Returns the list of equations formed by equating each coefficient of variable var^n in z1 to the corresponding coefficient of var^n in z2. z1 and z2 can be polynomials or ratios of polynomials.
Returns the polynomial decomposition of poly_1 with respect to
var. Note that decompose is not currently working.
The only argument, mat, must be an array having at least one row of two expressions: [[x1,y1],[x2,y2],…]. It is an error if there are any duplicates in the first column of the second argument,
interp returns a polynomial function poly(@1) such
that
mat[1,2]=poly(mat[1,1]),
mat[2,2]=poly(mat[2,1]), etc.
There is a variant of the interp command that takes multiple
vector arguments instead of a matrix. These vectors represent points
to be interpolated over. The same constraints apply as in the matrix
version. All the variants of the interpolation procedure described
later have both these forms.
(%0032) interp([[2, 3], [0, -1]]);
%0032: -1 + 2 @1
(%0033) interp([[2, 3], [1, z]]);
%0033: -3 + 3 @1 + (2 - @1) z
(%0034) interp([2, 3], [y, z]);
- 3 @1 + 3 y + (-2 + @1) z
%0034: --------------------------
-2 + y
This is the same as the interp command.
This is similar to interp command with an added option of
including derivative values when defining points. The same constraints
apply as in interp. You can choose to specify some number of
derivatives for each point. That number does not have to be the same
for all points.
(%0035) interp.newton([-1, 0], [0, 1], [1, 0]);
2
%0035: 1 - @1
(%0036) interp.newton([-1, 0], [0, 1, 0, 20], [1, 0]);
2 4
%0036: 1 + 10 @1 - 11 @1
(%0037) interp.newton([-1, 0], [0, 1, 0, a], [1, 0]);
4 2 4
2 - 2 @1 + (@1 - @1 ) a
%0037: -------------------------
2
The same as interp in its functionality, but uses Neville
form when constructing the polynomial.
The Jacal command factor takes as input an integer and returns a
list of the prime numbers that divide it, each occurring with the
appropriate multiplicity in the list. If the number is negative, the
list will begin with -1.
The results of the factor command are shown in a special
factored format, which appears as the product of the factors.
(%0038) factor(120);
3
%0038: 2 3 5
(%0039) factor(-120);
3
%0039: -1 2 3 5
Given a univariate ratio of polynomials polyratio, returns a matrix of factors and exponents.
As above, the results are shown in factored form.
(%0040) factor((14*x^4-10/68*x^-5)/(5*x^2+1));
9
-5 + 476 x
%0040: ------------------
2 5
2 17 (1 + 5 x ) x
(%0043) factor(x*y);
%0043: x y
(%0044) factor((x+a)*(y^4-z));
4
%0044: -1 (a + x) (- y + z)
(%0045) factor((x+u*a^3)*(y^4-z));
3 4
%0045: -1 (a u + x) (- y + z)
(%0046) factor((x+u*a^3)^2*(y^4-z)/((x+1)*(u^2-v^2)));
4 3 2
(- y + z) (a u + x)
%0046: -------------------------
(- u + v) (u + v) (1 + x)
(%0047) factor(200*(-1*x+1+y)*(u-r^6)*(21*x+2-t^4));
6 4 2 3
%0047: (- r + u) (2 - t + 21 x) (1 - x + y) 5 2
(%0048) factor(2*(a+u)*(-v+b)*(a*x+y)^2);
2
%0048: -1 2 (a + u) (- b + v) (a x + y)
(%0049) factor(2*(a+u)*(-v+b)*(a*x+y)^2/((u^2-v^2)*(11*x+55)));
2
2 (a + u) (- b + v) (a x + y)
%0049: ------------------------------
11 (- u + v) (u + v) (5 + x)
(%0050) factor((c^3*u+b*a)*(b*b*a+v*p^2*q^2*c));
3 2 2 2
%0050: (a b + c u) (a b + c p q v)
(%0051) factor((2*z+y-x)*(y^3-a*x^2)*(b*z^2+y));
2 3 2
%0051: (- a x + y ) (- x + y + 2 z) (y + b z )
(%0052) factor((a*a*b*z+d)*(2*a*b*b*z+c));
2 2
%0052: (d + a b z) (c + 2 a b z)
(%0053) factor((a*a*b*z+d)*(2*a*b*b*z+c)*((u+a)*x+1));
2 2
%0053: (1 + (a + u) x) (d + a b z) (c + 2 a b z)
(%0054) factor(a*(z+1)/4);
a (1 + z)
%0054: ---------
2
2
The rest of this section documents commands from the factoring package. To use this package, execute the following command from the JACAL prompt:
require("ff");
Several of these commands return a matrix. The first column contains the factors and the second column contains the corresponding exponent.
Given a primitive univariate polynomial poly, calculate the square free factorisation of poly. A primitive polynomial is one with no factors (other than units) common to all its coefficients.
Given a monic polynomial poly, a prime p, and a positive
integer m, calculate the square free factorisation of poly
in GF(p^m)[x]. If m is not supplied, 1 is assumed.
(%0059) ffsff(x^5+x^3+1, 53);
[ 2 3 ]
[ 16 - 22 x + 26 x + x 1 ]
%0059: [ ]
[ -13 + x 2 ]
Given a square-free univariate polynomial poly and an integer power of a prime, q, returns (as a bunch) the irreducible factors of poly.
(%0060) berl(x^5+x^3+2, 53);
2 2
%0060: [1 + x, 5 - 26 x + x , 11 + 25 x + x ]
Returns the partial fraction expansion of a rational univariate polynomial polyratio. The denominator of polyratio must be square free. This code is still being developed.
JACAL has the ability to manipulate and simplify functions defined by first order linear differential equations.
The following functions and their reductions are defined by statements in init.math.
Represents the exponential function of scalar expression.
(%0043) exp(1+x); %0043: exp(1 + x) (%0044) exp(0); %0044: 1
Represents the natural logarithm of scalar expression.
(%0045) log(1+x);
%0045: log(1 + x)
(%0046) exp(5*log(a));
5
%0046: a
%expt is equivalent to
exponent*log(expression). If exponent is an
integer, it simplifies to a power of expression; a fractional
exponent does not.
(%0048) %expt(a,5);
5
%0048: a
(%0049) %expt(a,1/5);
log(a)
%0049: exp(------)
5
(%0050) a^(1/5);
1/5
%0050: a
These are the tangent and arctangent functions, from which all the other trigonometric functions are defined.
The standard trigonometric functions and their inverses.
(%0051) tan(atan(x));
%0051: x
(%0052) atan(tan(x));
%0052: x
(%0053) tan(2*atan(x));
2 x
%0053: ------
2
1 - x
(%0054) tan(3*atan(x));
3
- 3 x + x
%0054: ----------
2
-1 + 3 x
(%0055) tan(4*atan(x));
3
- 4 x + 4 x
%0055: --------------
2 4
-1 + 6 x - x
(%0056) atan(2*tan(x));
%0056: atan(2 tan(x))
(%0057) sin(3*asin(x));
3
%0057: - 3 x + 4 x
The Lambert W function defined as the inverse of z=%W*exp(%W).
This equivalent function has the name which MAXIMA uses. It is defined as:
lambert_w(z) :: lambert_w(z)'/z'=lambert_w(z)/(z*(1+lambert_w(z)));
lambert_w(log(x)*exp(log(x))) does not reduce to log(x) because
the principal branch of the Lambert-W function reduces only when
x>1/e.
These are the commands used to define transcendental functions.
func(x) :: func(x)'/x' = expression
Where expression is a function of func(x) and/or x, defines the differential equation for func.
inv ::~ func; inv(x) ::~ expression;
Defines inv as the inverse of func or expression.
func(const1) ::= const2
Where const1 and const2 evaluate to constants, sets an initial condition for the differential equation defining func.
The order in which initial conditions are defined matters; the first initial condition defined is used to vet potential solutions for differential equations.
The file init.math also defines expression-valued integer recurrences which generate the reduction of a transcendental function composed with an integer multiple of its inverse function. In the future these recurrences will be generated automatically from the differential equations.
ident[index] := scalar-expression
Defines ident as a memoized recurrence. The
scalar-expression can be any expression, and may include
references to ident or other memoized recurrences with integer
argument [ixpr] where ixpr evaluates to a
non-negative integer. The result of such a reference may be a
function; that function can take arguments within parentheses after a
[ixpr] argument.
ident[integer] ::= scalar-expression
Sets an initial condition. This is necessary to prevent runaway recursion if a recurrence does index arithmetic. Factorial can be defined as:
(%0039) fact[n] := n*fact[n-1]; fact[n]: n * fact[n - 1] (%0039) fact[0] ::= 1; (%0040) fact[3]; %0040: 6 (%0041) fact[7]; %0041: 5040
The Jacal command differential computes the derivative of the
expression expr with respect to a generic derivation. It is
generic in the sense that nothing is assumed about its effect on the
individual variables. The derivation is denoted by a right quote.
(%0061) differential(x^2+y^3);
2
%0061: 2 x x' + 3 y y'
(%0062) (x^2+y^3)';
2
%0062: 2 x x' + 3 y y'
The Jacal command diff computes the derivative of the expression
expr with respect to var1, ….
(%0063) diff(x^2+y^3,y);
2
%0063: 3 y
The Jacal command partial computes the partial derivative of the
expression expr with respect to var1, ….
(%0064) partial(x^2+@1^3,1);
2
%0064: 3 @1
Returns the indefinite integral of rational expression expr, if that integral is a rational expression containing at most one radical involving var.
(%0065) integrate((3+x^2)*(1+x^2)^(2/3)/(3+6*x^2+3*x^4),x);
2 2/3
x (1 + x )
%0065: -------------
2
1 + x
(%0066) integrate((1+x^2)^(2/3),x);
;;; could-not-find-algebraic-anti-derivative
non-decreasing-rxd 2 vs 0
(%0066) integrate(x*(1+x^2)^(2/3),x);
2 2 2/3
(3 + 3 x ) (1 + x )
%0066: ----------------------
10
If the indefinite integral of rational expression expr is a
rational expression (optionally including a radical involving
var), then integrate returns the difference of that
integral evaluated at b and a.
(%0067) integrate(x*(1+x^2)^(2/3),x,0,1);
2/3
-3 + 6 2
%0067: -----------
10
In JACAL, a matrix is just a bunch of equal length
bunchs, and this is the structure that the matrix operations
currently supported by JACAL (ncmult(), ^^, transpose(), etc.) expect.
A row-vector is coded like [[a,b,c]]; a column-vector is coded
by [[a],[b],[c]] or [[a,b,c]]^^t or [a,b,c]^^t.
[elt_1, elt_2, …]
To collect any number of Jacal objects into a bunch, simply enclose them
in square brackets. For example, to make the bunch whose elements are
1, 2, 4, type [1, 2, 4]. One can also nest
bunches, for example, [1, [[1, 3], [2, 5]], [1, 4]].
A bunch whose only element is [1, 2, 3] is a row vector, which
displays as [1 2 3]. The bunch has commas; the row vector does
not.
(%0068) B1:bunch(1, 2, 3); B1: [1, 2, 3] (%0068) B2:[B1]; B2: [ 1 2 3 ] (%0068) [B2]; %0068: [ [1, 2, 3] ] (%0069) [[[1, 2, 3]]]; %0069: [ [1, 2, 3] ]
Removes bunch nesting from bnch, returning a single bunch of the constituent expressions and equations.
(%0070) flatten([a, [b, [c, d]], [5]]); %0070: [a, b, c, d, 5]
The command ident takes as argument a positive integer n
and returns an nxn identity matrix. This is sometimes more
convenient than obtaining this same matrix using the command
scalarmatrix.
(%0071) ident(4);
[ 1 0 0 0 ]
[ ]
[ 0 1 0 0 ]
%0071: [ ]
[ 0 0 1 0 ]
[ ]
[ 0 0 0 1 ]
The command scalarmatrix takes as inputs a positive integer
size and an algebraic expression entry and returns an
n * n diagonal matrix whose diagonal entries are all
equal to entry, where n = size.
(%0072) scalarmatrix(3, 6);
[ 6 0 0 ]
[ ]
%0072: [ 0 6 0 ]
[ ]
[ 0 0 6 ]
The Jacal command diagmatrix takes as input a list of objects and
returns the diagonal matrix having those objects as diagonal entries. In
case one wants all of the diagonal entries to be equal, it is more
convenient to use the command scalarmatrix.
(%0073) diagmatrix(12,3,a,s^2);
[ 12 0 0 0 ]
[ ]
[ 0 3 0 0 ]
%0073: [ ]
[ 0 0 a 0 ]
[ ]
[ 0 0 0 2 ]
[ s ]
(%0074) diagmatrix([1,2],2);
[ [1, 2] 0 ]
%0074: [ ]
[ 0 2 ]
Here, poly_1 and poly_2 are polynomials and var is a
variable. The function sylvester returns the matrix introduced
by Sylvester (A Method of Determining By Mere Inspection the
Derivatives from Two Equations of Any Degree, Phil.Mag. 16 (1840)
pp. 132-135, Mathematical Papers, vol. I, pp. 54-57) for computing the
resultant of the two polynomials poly_1 and poly_2 with
respect to the variable var. If one wants to compute the resultant
itself, one can simply use the command resultant with the same
syntax.
(%0075) sylvester(a0 + a1*x + a2*x^2 + a3*x^3, b0 + b1*x + b2*x^2, x);
[ a3 a2 a1 a0 0 ]
[ ]
[ 0 a3 a2 a1 a0 ]
[ ]
%0075: [ b2 b1 b0 0 0 ]
[ ]
[ 0 b2 b1 b0 0 ]
[ ]
[ 0 0 b2 b1 b0 ]
The function genmatrix takes as arguments a function of two
variables and two positive integers, rows and cols. It
returns a matrix with the indicated numbers of rows and columns in which
the $(i,j)$th entry is obtained by evaluating function at
$(i,j)$. The function may be defined in any of the ways available in
Jacal, i.e previously by an explicit algebraic definition, by an
explicit lambda expression or by an implicit lambda expression.
(%0076) genfun: @1^2+@2^2;
2 2
genfun: @1 + @2
(%0076) genmatrix(genfun,3,5);
[ 2 5 10 17 26 ]
[ ]
%0076: [ 5 8 13 20 29 ]
[ ]
[ 10 13 18 25 34 ]
The rank of matrix is the maximal number of linearly independent columns of matrix, which is always equalt to the maximal number of linearly independent rows of matrix.
(%0077) rank([[0,0],[0,0]]); %0077: 0 (%0078) rank([[0,0],[0,1]]); %0078: 1 (%0079) rank([[2,0],[0,1]]); %0079: 2 (%0080) rank([[b,c],[0,a]]); %0080: 2 (%0081) rank([[b,c,d],[a,0,a],[e,f,a]]); %0081: 3
The command row returns the ith row of the matrix
matrix, where i = int. If int is larger than
the number of rows of matrix, then Jacal prints an error message.
The corresponding command for columns of a matrix is col.
(%0082) U1:[[1, 2, 3], [1, 5, 3]];
[ 1 2 3 ]
U1: [ ]
[ 1 5 3 ]
(%0082) row(U1, 2);
%0082: [1, 5, 3]
The command col is used to extract a column of a matrix. Here,
matrix is a matrix and integer is a positive integer. It
is an error if that integer exceeds the number of columns.
(%0084) C1:[[1,2,4],[2,5,6]];
[ 1 2 4 ]
C1: [ ]
[ 2 5 6 ]
(%0084) col(C1,2);
[ 2 ]
%0084: [ ]
[ 5 ]
The command minor returns the submatrix of matrix
obtained by deleting the ith row and the jth column.
(%0085) M3:[[1,2,3],[3,1,5],[5,2,7]];
[ 1 2 3 ]
[ ]
M3: [ 3 1 5 ]
[ ]
[ 5 2 7 ]
(%0085) minor(M3,3,1);
[ 2 3 ]
%0085: [ ]
[ 1 5 ]
The command cofactor returns the determinant of the i,
j minor of matrix.
The function rref is used to access elements of bunches. It
can also access elements nested at lower levels in a bunch. In
particular, it can also access matrix elements. In the above syntax,
bunch is the bunch whose parts one wishes to access, and n,
int_1, int_2, …, int_n are positive integers.
It returns the int_n-th element of the int_{n-1}-th element
of … of the int_2-th element of the int_1-th element
of bunch. One can have n = 0. In that case, rref
simply returns the bunch.
(%0088) [[1,2,3],[1,4,6],3] [2] [3]; %0088: 6 (%0089) [a,b] [2]; %0089: b
Computes the transpose of (matrix).
(%0000) transpose([[a,b],[c,d]]);
[ a c ]
%0000: [ ]
[ b d ]
(%0001) [[a,b],[c,d]]^^t;
[ a c ]
%0001: [ ]
[ b d ]
The Jacal command determinant computes the determinant of a
square matrix. Attempting to take the determinant of a non-square
matrix will produce an error message.
(%0008) A1:[[1,2],[6,7]];
[ 1 2 ]
A1: [ ]
[ 6 7 ]
(%0008) determinant(A1);
%0008: -5
The characteristic polynomial of matrix:
determinant(matrix - I var)
Matrix multiplication.
(%0009) A1:[[1, 2, 3], [5, 2, 7]];
[ 1 2 3 ]
A1: [ ]
[ 5 2 7 ]
(%0009) A2:[[3, 2], [6, 4]];
[ 3 2 ]
A2: [ ]
[ 6 4 ]
(%0009) A2 . A1;
[ 13 10 23 ]
%0009: [ ]
[ 26 20 46 ]
The infix operator ^^ is used for raising a square matrix to an
integral power.
(%0010) A3:[[1, 0], [-1, 1]];
[ 1 0 ]
A3: [ ]
[ -1 1 ]
(%0010) A3^^3;
[ 1 0 ]
%0010: [ ]
[ -3 1 ]
Negative exponents raise the inverse matrix to a power.
(%0000) A4: [[a, b], [c, d]];
[ a b ]
A4: [ ]
[ c d ]
(%0000) A4^^-1;
[ d - b ]
[ ----------- ----------- ]
[ - b c + a d - b c + a d ]
[ ]
%0000: [ - c a ]
[ ----------- ----------- ]
[ - b c + a d - b c + a d ]
(%0001) A4^^-2;
[ 2 - a b - b d ]
[ b c + d ------------------------- ]
[ ------------------------- 2 2 2 2 ]
[ 2 2 2 2 b c - 2 a b c d + a d ]
[ b c - 2 a b c d + a d ]
[ 2 ]
%0001: [ - a c - c d a + b c ]
[ ------------------------- ------------------------- ]
[ 2 2 2 2 2 2 2 2 ]
[ b c - 2 a b c d + a d b c - 2 a b c d + a d ]
(%0002) A4 . A4.1;
[ 1 0 ]
%0002: [ ]
[ 0 1 ]
(%0003) A4.1 . A4;
[ 1 0 ]
%0003: [ ]
[ 0 1 ]
(%0004) A4.2 . A4 . A4;
[ 1 0 ]
%0004: [ ]
[ 0 1 ]
The Jacal function dotproduct returns the dot product of two
row vectors of the same length. It will also give the dot product of
two matrices of the same size by computing the sum of the dot products
of the corresponding rows or, what is the same, the trace of one
matrix times the transpose of the other one.
(%0005) V1: [1,2,3]; V2: [3,1,5]; V1: [1, 2, 3] V2: [3, 1, 5] (%0005) dotproduct(V1, V2); %0005: 20
The Jacal command crossproduct computes the cross product of two
vectors. By definition, the two vectors must each have three
components.
(%0007) crossproduct([1,2,3],[4,2,5]); %0007: [4, 7, -6]
The tensors supported by JACAL are an extension of the matrix
structure (i.e., a bunch of bunches of bunches …) with the added
stipulation that all dimensions of the tensor be the same length
(e.g., 4x4x4). The number of dimensions (indices) in a tensor is its
rank: A scalar is a tensor of rank 0; a vector is a rank 1 tensor; a
matrix has rank 2; and so on.
Further, just as matrix binary operations place restrictions on the matrices involved (e.g., the row/column length requirement for matrix multiplication), the tensor binary operations require that the dimensions of each tensor be of the same length. For example, you could not multiply a 3x3 tensor and a 4x4x4 tensor.
JACAL’s tensors do not support the construct of contravariant and covariant indices. Users must keep track of this information themselves, and perform the necessary operations with an appropriate metric so that the "index gymnastics" is performed correctly.
JACAL currently supports four tensor operations: tmult,
contract, indexshift, and indexswap. Each of these is
described in detail below.
To use JACAL’s tensor operations, execute the following command from the JACAL prompt:
require("tensor");
To see tensor examples, download rw.math from the JACAL website
https://www.gnu.org/software/jacal/. Typing
batch("rw.math"); will execute the commands in the file,
computing tensors for The Robertson-Walker Cosmology Model. You can
then view a tensor by typing its label (name before ‘:’) followed
by a semicolon.
(%0001) metric_ll: diagmatrix((S(x4))^2/(1 - k * x1^2), (S(x4))^2 * x1^2, (S(x4))^2 * x1^2 * (sin(x2))^2, - 1) (%0002) metric_uu: diagmatrix(1/metric_ll[1][1], 1/metric_ll[2][2], 1/metric_ll[3][3], 1/metric_ll[4][4]) (%0002) metric_ul: ident(4) (%0002) det_metric: determinant(metric_ll) (%0002) d_metric_lll: indexshift([diff(metric_ll, x1), diff(metric_ll, x2), diff(metric_ll, x3), diff(metric_ll, x4)], 1, 3) (%0002) Christoffel_ull: (tmult(metric_uu, d_metric_lll, 2, 1) + indexswap(tmult(metric_uu, d_metric_lll, 2, 1), 2, 3) - tmult(metric_uu, d_metric_lll, 2, 3))/2 (%0002) d_Christoffel_ulll: indexshift([diff(Christoffel_ull, x1), diff(Christoffel_ull, x2), diff(Christoffel_ull, x3), diff(Christoffel_ull, x4)], 1, 4) (%0002) R_temp: d_Christoffel_ulll + indexshift(tmult(Christoffel_ull, Christoffel_ull, 2, 1), 2, 4) (%0002) Riemann_ulll: indexswap(R_temp, 3, 4) - R_temp (%0002) Ricci_ll: contract(Riemann_ulll, 1, 3) (%0002) Ricci_ul: tmult(metric_uu, Ricci_ll, 2, 1) (%0002) Ricci_uu: tmult(Ricci_ul, metric_uu, 2, 1) (%0002) scalar_curv: contract(Ricci_ul, 1, 2) (%0002) Einstein_ll: Ricci_ll - scalar_curv * metric_ll/2 (%0002) Einstein_ul: Ricci_ul - scalar_curv * metric_ul/2 (%0002) Einstein_uu: Ricci_uu - scalar_curv * metric_uu/2 (%0002)
(%0002) Einstein_uu;
[ 2 2 ]
[ - k + k x1 0 ]
[ ------------ 0 ]
[ 4 k ]
[ (S(x4)) -------------- 0 0 ]
[ 2 4 ]
[ 0 - x1 (S(x4)) 2 0 ]
Einstein_uu: [ k + k (tan(x2)) ]
[ 0 0 ------------------------- 0 ]
[ 2 4 2 ]
[ 0 0 - x1 (S(x4)) (tan(x2)) 3 k ]
[ -------- ]
[ 0 2 ]
[ (S(x4)) ]
tmult takes a minimum of two arguments which are the tensors on
which the multiplication operation is to be performed.
With no additional arguments, tmult will produce the outer
product of the two input tensors. The rank of the resulting tensor is
the sum of the inputs’ ranks, and the components of the result are
formed from the pair-wise products of components of the inputs. For
example, for the input tensors x[a,b] and y[c]
z:tmult(x,y); ⇒ z[a,b,c] = x[a,b]*y[c]
With an additional argument, tmult will produce the inner product
of the two tensors on the specified index. For example, given
x[i,j] and y[k,l,m]
z:tmult(x,y,3);
⇒
length
-----
\
z[a,b,c] = > x[a,q] * y[b,c,q]
/
-----
q = 1
Note that in this case x only has 2 indices. All of JACAL’s tensor
operations modify index inputs to be between 1 and the rank of the
tensor. Thus, in this example, the 3 is modified to 2 in the case of x.
As another example, with x[i,j,k] and y[l,m,n]
z:tmult(x,y,2);
⇒
length
-----
\
z[a,b,c,d] = > x[a,q,b] * y[c,q,d]
/
-----
q = 1
With four arguments, tmult produces an inner product of the two
tensors on the specified indices. For example, for x[i,j] and
y[k,l,m]
z:tmult(x,y,1,3);
⇒
length
-----
\
z[a,b,c] = > x[q,a] * y[b,c,q]
/
-----
q = 1
Note that matrix multiplication is the special case of an inner product (of
two "two dimensional matrices") on the second and first indices,
respectively: tmult(x,y,2,1) ≡ ncmult(x,y)
Finally, tmult handles the case of a scalar times a tensor, in which case each component of the tensor is multiplied by the scalar.
The contraction operation produces a tensor of rank two less than a given tensor. It does this by performing a summation over two of the indices of the given tensor, as clarified in the examples below.
contract takes at least one argument which is the tensor on which the
contraction operation is to be performed. One or two additional arguments
may be provided to specify the indices to be used in the summation. If no
additional arguments are provided, the summation is performed over the
first and second indices. With one additional argument, the summation is
over the specified index and the one following it (e.g., if 3 is specified,
the third and fourth indices are used). With two additional arguments, the
summation is performed over the indices specified. The actual indices used
will be constrained to be between 1 and the rank of the tensor.
Examples:
1) For a square matrix (tensor of rank 2), contract returns a scalar that
is the sum of the diagonal elements of the matrix.
2) Given x[i,j,k,l], the command
y:contract(x,2,4);
produces:
length
-----
\
y[a,b] = > x[a,q,b,q]
/
-----
q = 1
Special cases: If contract is given a scalar (rank 0 tensor) as input,
it just returns the scalar. For a vector (tensor of rank 1), contract
returns a scalar that is the sum of the elements of the vector.
indexshift rearranges the indices of a tensor. It is one of two
generalizations of the matrix transpose operation (cf. indexswap).
indexshift takes at least one argument which is the tensor on which the
index shifting is to be performed. One or two additional arguments may be
provided to specify the index and the position to which it is to be
shifted. If no additional arguments are provided, the first index of the
tensor is shifted to the second position (equivalent the matrix transpose
operation). If one additional argument is provided, it specifies the index
to be shifted, and that index will be shifted "to the right" one position
(e.g., if 3 is specified, the third index will be shifted to the forth
position). If two additional arguments are provided, the first specifies
the index and the second specifies the position to which it is to be
shifted. The actual index shifted and its shifted position will be
constrained to be between 1 and the rank of the tensor.
For example, given x[a,b,c,d], the command
y:indexshift(x,1,3); produces a tensor y such that
y[a,b,c,d] ≡ x[b,c,a,d]. In this example, the element
that was in position [a,b,c,d] in x will be in position
[b,c,a,d] in y.
Special cases: If indexshift is given a scalar (rank 0 tensor) as input,
it just returns the scalar. For a vector (tensor of rank 1), indexshift
transposes the 1-by-n matrix (row vector) to an n-by-1 matrix (column
vector).
indexswap rearranges the indices of a tensor. It is one of two
generalizations of the matrix transpose operation (cf. indexshift).
indexswap takes at least one argument which is the tensor on which index
swapping is to be performed. One or two additional arguments may be
provided to specify the indices to be swapped. If no additional arguments
are provided, the first and second indices of the tensor are swapped
(equivalent the matrix transpose operation). With one additional
argument, the specified index is swapped with the one following it (e.g.,
if 2 is specified, the second and third indices will be swapped). If two
additional arguments are provided, they specify the indices to be swapped.
The actual indices used will be constrained to be between 1 and the rank of
the tensor.
For example, given x[a,b,c,d], the command y:indexswap(x,2,4);
produces a tensor y such that y[a,b,c,d] = x[a,d,c,b]. In this
example, the element that was in position [a,b,c,d] in x will be
in position [a,d,c,b] in y.
Special cases: If indexswap is given a scalar (rank 0 tensor) as input,
it just returns the scalar. For a vector (tensor of rank 1), indexswap
transposes the 1-by-n matrix (row vector) to an n-by-1 matrix (column
vector).
Jacal has the ability to work with lambda expressions, via the command
lambda. Furthermore, Jacal always converts user definitions of
functions by any method into lambda expressions and converts the dummy
variables of the function definition into symbols such as 1,
2, …. Jacal can manipulate lambda expressions by
manipulating their function parts, as in ‘e14’ below. Jacal can
also invert a function using the command finv.
(%0012) lambda([x],x^2);
2
%0012: @1
(%0013) lambda([x,y,z],x*y*z);
%0013: @1 @2 @3
(%0014) %0012 + %0013;
2
%0014: @1 + @1 @2 @3
The arguments matrix1, matrix2, … must have the same
shape. The command elementwise returns a new matrix formed by
applying function to each tuple of elements of matrix1,
matrix2, ….
(%0015) elementwise(foo,[a, b], [c, d]);
%0015: [foo(a, c), foo(b, d)]
(%0016) elementwise(@1+5*@2,[a, b], [c, d]);
%0016: [a + 5 c, b + 5 d]
(%0017) elementwise(@1-@2,[9,8,7],[[1,0],[4,5],[6,3]]);
[ 8 9 ]
[ ]
%0017: [ 4 3 ]
[ ]
[ 1 4 ]
function^^-1
The command finv takes as input a function of one variable and
returns the inverse of that function. The function may be defined in any
of the ways permitted in Jacal, i.e. by an explicit algebraic
definition, by an explicit lambda expression or by an implicit lamba
expression. If f is the function, then typing f^^-1 has the
same effect as typing finv(f).
(%0008) w(t):=t+1; w(t): t + 1 (%0009) finv(w); %0009: -1 + @1
The symbol % represents the last expression obtained by Jacal. It
can be used in formulas like any other constant or variable or
expression.
(%0010) 5+x;
%0010: 5 + x
(%0011) %^2-%;
2
%0011: 20 + 9 x + x
The command batch is used to read in a file containing scripts
of Jacal commands. Here, filename is a string in double
quotes. The precise way in which one refers to a file is, of course,
system dependent.
Displays expr in TeX, the Scheme programming language, Jacal’s two-dimensional output format, Jacal’s infix input format, or compressed infix format respectively.
If one these top-level function calls is prefixed with %horner,
the output will be in Horner’s rule format, multiplication instead of
exponentiation.
(%0002) disp2d((x-1)^3/(x+1)^3);
2 3
-1 + 3 x - 3 x + x
--------------------
2 3
1 + 3 x + 3 x + x
(%0002) horner(disp2d((x-1)^3/(x+1)^3));
-1 + (3 + (-3 + x) x) x
-----------------------
1 + (3 + (3 + x) x) x
(%0002) scheme((x-1)^3/(x+1)^3);
(/ (+ (- (+ -1 (* 3 x)) (* 3 (expt x 2)))
(expt x 3))
(+ 1 (* 3 x) (* 3 (expt x 2)) (expt x 3)))
(%0002) standard((x-1)^3/(x+1)^3);
(-1 + 3 * x - 3 * x^2 + x^3)/(1 + 3 * x + 3 * x^2 + x^3)
(%0002) std((x-1)^3/(x+1)^3);
(-1+3*x-3*x^2+x^3)/(1+3*x+3*x^2+x^3)
(%0002) tex((x-1)^3/(x+1)^3);
{{-1+3\,x-3\,x^{2}+x^{3}}\over{1+3\,x+3\,x^{2}+x^{3}}}
Read TeX expression string.
The tex command reads its double-quoted argument as a TeX
expression
Read Scheme double-quoted string argument as Scheme cdoe.
(%0000) scheme("(- (expt b 2) (* 4 a c))");
2
%0000: b - 4 a c
Reads double-quoted string in Jacal’s infix input format.
The command commands produces a list of all of the command
available in Jacal. It is called as a function of no arguments.
commands();
% * + - / = ^ ^^ abs args arity augcoefmatrix b+/- b-/+ batch bunch cabs canon chain chainables charpoly coeff coeffs coefmatrix cofactor col commands compose content continue crossproduct decompose degree denom depends derivative describe determinant diagmatrix diff differential discriminant disp2d divide dotproduct elementwise eliminate equatecoeffs example extensions definition factorial factors finv flatten func gcd genmatrix help ident imagpart integrate interp interp.lagrange interp.neville interp.newton jacobi jacobian listofvars load matrix minor mod monomial ncmult negate normalize num or over parallel partial poly polyelim prime? qed quit rank raw realpart require restart resultant row rref scalarmatrix scheme scheme2d set shade shadows show squarefreefactors squarefreefactorslist standard std sylvester system taylor terms tex transcript transpose u+/- u-/+ varpri vd verify wronski wronskian
The command describe is the heart of the builtin help facility of
Jacal. Here, command is a string which is the name of a command
and describe produces a brief description of the command and in
many cases includes an example of its use. Together with the command
commands(), which prints a list of all available Jacal commands,
and the command example, which gives an example of the use of the
command, one can in principle use Jacal without a manual after one has
learned how to get started.
(%0012) describe(col); built-in-operation column. column of a matrix (%0012) describe(resultant); built-in-operation resultant. The result of eliminating a variable between 2 equations (or polynomials). (%0012) describe(/); built-in-operation Quotient, division, divide, over. a/b
Here, command is a string which is the name of a Jacal command.
example gives an example of the use of the command.
See also describe.
(%0013) example(*); a * 7 %0013: 7 a
Note: the command example executes the example it gives. This
can lead to unpredictable results if the variables and constants in
the example have already been given values by the user.
The Jacal command load takes as input a string and reads in a
‘Scheme’ file whose name is obtained by appending the extension
.scm to the string. If you want to read in a file of Jacal
commands, do not use load. Instead use the command
batch. To load in the file tensor.scm,
(%0014) load("tensor.scm");
"tensor.scm"
Exit from Jacal to Scheme. With interactive Scheme systems (such as
SCM), It does not return you to the operating system. Instead it
suspends Jacal and returns you to the underlying scheme. You can return
to the Jacal session where you left off by simply typing (math).
If you do not wish to return to Jacal but really want to terminate the
session and return to the operating system, then after typing
qed;, type (slib:exit) or use quit.
Exit directly from Jacal to the operating system. You will not be able to continue your Jacal session.
(%0015) qed; scheme > (math) Type qed; to return to Scheme, type help; for help. (%0015) quit(); unix>
One can issue commands to the operating system without leaving Jacal. To
do this, one uses the command system. For example, in a UNIX
operating system, the command system("ls"); will print the
directory. One way in which the command system might be
especially useful is to edit files containing Jacal scripts without
leaving Jacal, particularly in non-UNIX machines or on machines without
GNU emacs.
(%0000) system("echo hi there");
hi there
%0000: 0
Prints a copy of the GNU General Public License
(%0001) terms();
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[ rest deleted for brevity]
The command transcript allows one to record a Jacal session. It
is called with the syntax transcript(string);, where
string is the name of the file in which one wants to keep the
transcript of the session. When one wishes to stop recording, one types
transcript();. One is then free to use transcript again
later in the session on another file. One can use it on the same file,
but the file is overwritten. Presently, the command transcript
does not echo commands to a file.
(%0001) a:[1,2,3];
a: [1, 2, 3]
(%0001) transcript("foo");
"foo"
(%0002) a;
a: [1, 2, 3]
(%0002) transcript();
(%0002) system("cat foo");
(%0002) a;
(%0002) transcript();%0002: 0
There are various flags that the Jacal user can control, namely the
Jacal command line prompt, the priority for printing terms in Jacal
output, the input grammar and the output grammar. For a discussion of
the various grammars please See Flags. The command show is
closely related, allowing one to see what the current settings are.
The command show enables the Jacal user to examine the current
setting of various flags as well as to list the flags that can be set
by the user and to display other information. To change the settings
of the flags, use the command set. To see all the information
accessible through the show command, type show all. To
see the available grammars, type show grammars. To see the
current input grammar type show ingrammar. To see the current
output grammar, type show outgrammar. To see the current
variable ordering, type show ordering.
(%0003) show all;
all debug echogrammar elims grammars horner ingrammar linkradicals
ordering outgrammar page phases priority prompt trace version width
(%0003) show prompt;
%0003: %0003
(%0000) show ordering;
@ %W (exp(@2*log(@1)))' ((tanh(@1))^(1/2))' ((1+(tan(@1))^2)^(1/2))'
((-1+(tanh(@1))^2)^(1/2))' (tanh(@1))' (tan(@1))' (log(@1))' (exp(@1^2))'
(exp(@1))' (exp(1))' (exp(-@2^2))' (exp(-@1^2))' (erf(@1*%i))' (erf(@1))'
(atanh(1/@1))' (atan(1/@1))' (atan(1))'
(atan((-@1*%i*(-1+@1^2)^(1/2))/(-1+@1^2)))'
(atan((-1+@1^2)^(1/2)/(-1+@1^2)))' (atan((-1+@1^2)^(1/2)))'
(atan(%i*(-1+@1^2)^(1/2)/@1))' exp(@2*log(@1)) (tanh(@1))^(1/2)
(1+(tan(@1))^2)^(1/2) (-1+(tanh(@1))^2)^(1/2) tanh(@1) tan(@1) log(@1)
exp(@1^2) exp(@1) exp(1) exp(-@2^2) exp(-@1^2) erf(@1*%i) erf(@1)
atanh(1/@1) atan(1/@1) atan(1) atan((-@1*%i*(-1+@1^2)^(1/2))/(-1+@1^2))
atan((-1+@1^2)^(1/2)/(-1+@1^2)) atan((-1+@1^2)^(1/2))
atan(%i*(-1+@1^2)^(1/2)/@1) tanh tan log fre exp erf atanh atan lambert_w
((atan(1))^(1/2))' (atan(1))^(1/2) @2' @1' (@1^(1/3))' (@1^(1/2))'
((-1+@1^2)^(1/2))' %i' @' %tanhQ[@1] %tanhQ[-1+@1] %tanhP[@1]
%tanhP[-1+@1] %tanQ[@1] %tanQ[-1+@1] %tanP[@1] %tanP[-1+@1] %expPQ[-1+@1]
@3 @2: @2 @1^(1/3) @1^(1/2) (-1+@1^2)^(1/2) %i @1: @1 %sqrt1 y x t
ordering c b a ? ::@ %tanhQ %tanhPQ %tanhP %tanQ %tanPQ %tanP %expPQ
"Currently in math mode."
(%0000) show outgrammar;
%0000: disp2d
(%0001) show ingrammar;
%0001: standard
(%0002) show grammars;
%0002: [null, raw, scheme, scheme2d, std, standard, disp2d, tex]
If one changes the prompt, string is a string of alphanumeric characters without quotes. After this command is executed, subsequent commands will cause new prompts to be obtained from string by incrementing it. If the prompt ends in a letter, it will be treated as a digit in base 26 and incremented. If it ends in a string of digits, that string will be treated as a number in base 10 and incremented. The remaining characters in the string will play no role in this incrementation.
(%0003) set prompt "az9Z"; (az9Z) a+b; az9Z: a + b (az9AA) a+b; az9AA: a + b (az9AB) set prompt "ok99"; (ok99) a+b; ok99: a + b (ok100) b+c; ok100: b + c
The following examples show how one changes the input grammar or the output grammar.
(%0000) a:[[[1,2,3]]];
a: [ [1, 2, 3] ]
(%0000) set outgrammar standard;
(%0000) a;
a: [[[1, 2, 3]]]
(%0000) set outgrammar scheme;
(%0000) a;
(define a #(#(#(1 2 3))))
(%0000) (1+x)^5;
(define %0000 (+ 1 (* 5 x) (* 10 (expt x 2)) (* 10 (expt x 3)) (* 5 (expt x 4)) (expt x 5)))
(%0001) set ingrammar scheme;
(%0001) (+ %0000 1);
(define %0002 (+ 2 (* 5 x) (* 10 (expt x 2)) (* 10 (expt x 3)) (* 5 (expt x 4)) (expt x 5)))
(set ingrammar disp2d)
(%0003) diagmatrix(3,6);
(define %0003 #(#(3 0) #(0 6)))
(%0004) set outgrammar disp2d;
(%0004) %0003;
[ 3 0 ]
%0003: [ ]
[ 0 6 ]
(%0004) set outgrammar standard;
(%0004) %0003;
%0003: [[3, 0], [0, 6]]
Note that in the above examples, it is possible to input and output
expressions in scheme by setting the ingrammar and/or outgrammar to
scheme. Doing so result in linear output (as with
standard grammar) as opposed to a two dimensional display (as
with disp2d). The analogue of disp2d for scheme output
is Scheme pretty-printing. To have such output, set the output
grammar to scheme2d.
(%0004) set outgrammar scheme2d;
(%0004) (1+x)^5;
(define %0004
(+ 1
(* 5 x)
(* 10 (expt x 2))
(* 10 (expt x 3))
(* 5 (expt x 4))
(expt x 5)))
Jacal also allows for output to be automatically typeset in TeX.
This can be quite useful if one wants to use the results of one’s
computations in published articles. Continuing with the example of
(1+x)^5 above, we have:
(%0005) set outgrammar tex;
(%0005) %0004;
%0004: 1+5\,x+10\,x^{2}+10\,x^{3}+5\,x^{4}+x^{5}
(%0005) (1+1/x)^3/(1-1/y)^4;
%0005: {{\left(1+3\,x+3\,x^{2}+x^{3}\right)\,y^{4}}\over{x^{3}-
4\,x^{3}\,y+6\,x^{3}\,y^{2}-4\,x^{3}\,y^{3}+x^{3}\,y^{4}}}
The following examples show how to set the priority of printing terms.
(%0000) a: [[[1,2,3]]]; a: [ [1, 2, 3] ] (%0000) show priority a; ;;; expl->var not a simple variable: [[[1 2 3]]] (%0000) show priority b; %0000: 3000 (%0001) show priority c; %0001: 3000 (%0002) b+c; %0002: b + c (%0003) c+b; %0003: b + c (%0004) set priority b 2000; (%0004) b+c; %0004: b + c (%0005) set priority b 4000; (%0005) b+c; %0005: c + b (%0006) %0002; %0002: b + c
| Jump to: | -
:
.
'
*
/
%
^
+
=
|
A B C D E F G H I L M N O P Q R S T U X |
|---|
| Jump to: | -
:
.
'
*
/
%
^
+
=
|
A B C D E F G H I L M N O P Q R S T U X |
|---|