Web REDUCE User Guide
Contents
- Desktop and Mobile Versions
- Main Page
- Input Editor
- REDUCE Menu
- File Menu
- View Menu
- Templates Menu
- Functions Menu
- Help Menu
- Controlling Web REDUCE via the URL Query String
Desktop and Mobile Versions
There are currently two versions of Web REDUCE: desktop and mobile. The desktop (normal) version allocates 1GB of memory and is a full build of REDUCE, including all packages. The mobile version allocates 256MB of memory and does not include the more specialised packages. The mobile version is currently necessary because of problems with memory management in mobile web browsers and not primarily because mobile devices lack physical memory. The mobile version runs on desktop browsers, but probably not vice versa!
You select the version you want to run by clicking the appropriate button on the start page, which you reach by selecting Web REDUCE in the main navigation panel. The desktop version is started by visiting the URL /web-reduce/ whereas the mobile version is started by visiting the URL /web-reduce/?mobile, which you can also do explicitly. The mobile version defaults to full window mode (see the View Menu) and tries to re-position the window contents after input events so that you can see the output, whereas the desktop version refocuses the input editor.
Main Page
Web REDUCE normally starts loading as soon as its main page is
opened and starts running as soon as it has loaded, which should
be almost instantaneous except for the first time you run it in a
particular browser or after an update to the Web REDUCE engine, in
which case there may be a noticeable pause. Web REDUCE will stop
when you close its main page; it is not necessary to explicitly
terminate REDUCE. However, you can stop and start Web REDUCE by
using the REDUCE Menu, and stop Web
REDUCE by executing the command BYE or QUIT,
as usual. To fully reset and restart Web REDUCE just reload its
main page.
The Web REDUCE main page consists of a menu bar and two panes, one above the other. The top pane displays all the REDUCE input and output in the current session. It is read-only. The bottom pane is an input editor that supports all the standard keyboard and mouse-based editing facilities normally provided by your platform. Both panes display vertical scroll bars when necessary. The top pane wraps input when possible and displays a horizontal scroll bar when necessary; text wraps in the input editor. The input editor can be resized vertically by dragged the bottom right-hand corner, and in Chromium-based browsers the I/O display can similarly be resized vertically by dragged the bottom right-hand corner. Input text can always be copied from the top pane; plain text output can also be copied but typeset mathematical output cannot currently be copied in such a way that it can be re-input into REDUCE.
Input Editor
You type (or paste) REDUCE input into the input editor pane, edit it as necessary, and then click on the Send Input button, which sends the input to REDUCE and echoes it in the top pane. This clears the input editor, but you can scroll through previous input (entered via the input editor) using the Earlier Input and Later Input buttons. Scrolling to input later than the last previous input clears the input editor pane back to its state before you started scrolling.
When keyboard focus is in the input editor pane, the following keyboard shortcuts are active:
| Keyboard Shortcut | Action |
|---|---|
| Control+Enter | Send Input (auto-terminated) |
| Control+Shift+Enter | Send Input (not auto-terminated) |
| Control+UpArrow | Earlier Input |
| Control+DownArrow | Later Input |
where Enter is the Return or Enter key and UpArrow / DownArrow are the cursor up / down keys, respectively.
Sending input to REDUCE strips any trailing white space and normally auto-terminates it by adding a semicolon if there was no final terminator. However, holding the Shift key while clicking on the Send Input button or pressing Control+Enter suppresses auto-termination.
You can edit previous input recalled into the input editor as necessary and then send it to REDUCE. Input can be multi-line, in which case REDUCE processes all the lines together. The Send Input action is disabled until REDUCE is running, and the Earlier Input and Later Input actions are disabled unless there is earlier or later input, respectively.
Holding down the Alt key during any of the above input gestures causes Web REDUCE to treat the keyboard input like file input with echo enabled, meaning that the input is echoed by REDUCE so that input statements and their output are interleaved. This only affects multi-statement input.
By default, matching delimiter pairs in the input editor are
highlighted by underlining the delimiters and their content when
the text cursor is immediately after a closing delimiter or
immediately before an opening delimiter. The delimiter pairs that
are highlighted are: brackets, (…) and
{…}; group statements,
<<…>>; block statements,
begin…end. Delimiter highlighting can be
turned on and off using an entry in the View menu.
Delimiter matching handles nested delimiters correctly and
partially ignores delimiters in strings, but not in comments since
comments are not expected in interactive input. An unmatched
closing or opening delimiter immediately before or after the text
cursor is highlighted in the same error style as used in the I/O
display.
Most Greek letters (both cases) input as Unicode characters via the input editor or the menus (see below) are converted to their TeX names when they are sent to REDUCE, and should then be handled appropriately and displayed as Greek letters in REDUCE output if typeset maths is enabled (which it is by default; see below). This facility is primarily intended for use by the Functions dialogues to allow conventional parameter names to be used, some of which are Greek. Superscript 2 is also converted to its ASCII equivalent. (Other non-ASCII characters may be similarly converted in later releases.)
REDUCE Menu
The REDUCE menu provides the following items:
- Start REDUCE
- Selecting this item clears the Input/Output Display and then starts Web REDUCE, which displays the usual CSL REDUCE start-up message. It is disabled if Web REDUCE is already running.
- Load Packages…
-
Selecting this item displays a list of the standard REDUCE packages available in this version of Web REDUCE and
allows you to load one or more (using the REDUCE
load_packagecommand). It is disabled unless REDUCE is running. The non-mobile version provides all the packages distributed with REDUCE, whereas the mobile version provides just the main packages, so the list is much shorter. The list is sorted alphabetically and excludes packages that are pre-loaded, but includes packages that autoload, which many do. - You can either select one or more packages and then click/tap the Load button at the bottom, or you can double-click/tap on a package to load just that package. To display the manual entry for a package (if there is one) in a new browser tab either select a single package and click/tap the Manual button at the bottom or right-click/tap-and-hold on a package. The Manual button is disabled unless precisely one package is selected. Clicking on a package selects or deselects it, and the Reset button clears all selections.
- Stop REDUCE
-
Selecting this item stops Web REDUCE and displays the message
"REDUCE stopped". It is disabled if Web REDUCE is not running.
Executing either of the usual commands
BYEorQUITshould have exactly the same effect. - Restart REDUCE
- Selecting this item stops Web REDUCE and then starts it again, as a convenient alternative to clicking on the above two menu items one after the other. It is disabled if Web REDUCE is not running.
- Clear I/O Display
- Selecting this item clears the Input/Output Display, but has no other effect.
- Print I/O Display
- Selecting this item prints the Input/Output Display, but has no other effect. It uses the normal printing facilities provided by the web browser, and prints the whole of the current contents of the Input/Output Display, not just the visible part. The printed version should look more-or-less identical to what is shown on the screen, including colour and typeset mathematics if enabled. This is, of course, subject to a suitable printer setup, but it seems to work well on Windows 10 outputting to a PDF file.
File Menu
The File menu uses the experimental File System Access API provided by Chromium-based browsers such as Chrome, Edge, and Opera on desktop platforms, which works well. On other browsers, such as Firefox, Safari and on mobile platforms, much cruder facilities have to be used, which work much less well. If you intend to use file input or output then I recommend that you use a Chromium-based browsers on a desktop platform! The File menu is enabled only when Web REDUCE is running, and provides the following items:
- Echo File Input
- When this check box is checked, input files are echoed to the screen or to the output file if one is active. It is checked by default.
- Input from File…
-
Selecting this item displays a file picker that allows a file
to be selected and input into Web REDUCE. This emulates the
REDUCE
INcommand, except that Web REDUCE currently supports only one input file at a time and files need not be terminated with;end;(although this should do no harm). Note that currently when input is from a file it is never coloured and only typeset mathematical output is coloured if I/O Colouring is enabled. Web REDUCE displays an information message that it is now inputting from the specified file. - Output to File…
-
Selecting this item displays a dialogue that allows a file
to be selected and output from Web REDUCE to be sent to it.
It is disabled when an output file is open. File output disables
typeset mathematics output temporarily so that the contents of
the output file should be plain ASCII text. This emulates the
REDUCE
OUTcommand, except that Web REDUCE currently supports only one open output file at a time. Web REDUCE displays an information message that it is now outputting to the specified file. - On Chromium-based desktop browsers, the normal file picker is used to select an output file, and if it already exists you can choose to overwrite it. On other browsers, a dialogue allows the default output file name to be edited, but the file will be output to a location determined by your browser, which you may be able to configure as one of your browser's settings. Also, your browser's normal download dialogue will appear when you shut the output file, which you must acknowledge appropriately, because saving the output file is unavoidably emulated as a download. If the output file already exists then the new file will be automatically renamed and the existing file will not be overwritten.
- Output Here
-
Selecting this item redirects output to the terminal, without
closing the output file. It is enabled only when output is
directed to a file. This emulates the REDUCE
OUT Tcommand. Web REDUCE displays an information message that it is now outputting to the terminal. - Output to Open File
-
Selecting this item redirects output to the previously
selected output file. It is enabled only when output is
redirected from a file back to the terminal. This emulates the
REDUCE
OUTcommand specifying the previously selected output file, except that Web REDUCE currently does not require (or allow) you to specify the file, since only one output file can be open. Web REDUCE displays an information message that it is now outputting to the specified file. - Shut Output File
-
Selecting this item closes the current output file and directs
output back to the terminal. It is enabled only when an output
file is open. This emulates the REDUCE
SHUTcommand, except that Web REDUCE currently does not require (or allow) you to specify the file to shut, since only one output file can be open. Web REDUCE displays an information message that it is now outputting to the terminal.
View Menu
The View menu provides the following items:
- Full Window
- When this box is checked, Web REDUCE hides content that is extraneous to the web app, namely the header and footer regions, navigation panel, page heading and MathJax logo, so that the web app uses the full browser window. This is primarily intended for use on small displays and is the default in mobile mode. In desktop mode, this box is unchecked by default.
- I/O Colouring
- When this box is checked, Web REDUCE displays input coloured red and output coloured blue in the Input/Output Display; otherwise the default colour (normally black) is used for both input and output. It is checked by default.
- Typeset Maths
- When this box is checked, Web REDUCE displays algebraic-mode mathematical output more-or-less as it would be typeset. It is checked by default. Output display will be significantly faster when Typeset Maths is turned off. Typeset output should appear very similar to that displayed by the CSL REDUCE GUI and TeXmacs since it is generated by the same REDUCE code, although in Web REDUCE it is displayed using the MathJax JavaScript library. Right-clicking on typeset math output pops up the MathJax context menu.
- Centre Typeset Maths
- When this box is checked, Web REDUCE displays typeset maths centred horizontally; otherwise it is left justified. It is checked by default.
- Highlight Matching Delimiters
- When this box is checked, the input editor underlines matching delimiters and their content. It is checked by default.
Templates Menu
The Templates menu facilitates construction of structured expressions and statements whose syntax might not be immediately obvious, especially to a novice. The template dialogues all provide hyperlinks to the key sections of the HTML version of the REDUCE Manual, which open in a new tab in your web browser. The dialogues all provide two buttons that apply the filled-in template: the Edit button inserts the template output into the input editor at the caret (current cursor position) or replacing any selected text; the Evaluate button sends the template output directly to REDUCE for evaluation, adding a terminator just as the Send Input button does. These buttons also close the dialogue. To close a template dialogue explicitly, click on the Close button.
If the template represents an operator with a primary operand then
this defaults to ws, which is convenient for simple
interactive calculations, but it can be changed to anything. The
templates provide some minimal input validation: for example, if
an element must be an explicit number (rather than a variable that
must evaluate to a number), the template will check this and
report an error immediately an inappropriate character is entered.
The template checks that all input has been provided that is
required for valid REDUCE syntax.
If output from a template dialogue (or function dialogue, see below) contains ws and is inserted into
the input editor then ws is automatically selected, ready to be replaced (if appropriate). This makes
it easy to build up complicated expressions from the outside in. Otherwise, the caret is left at the end of the
inserted text.
Templates remember their previous input, but clicking on the Reset button resets them to their initial state when Web REDUCE was first started.
These templates are intended only for creating simple structures, but they can form the basis for arbitrarily complex structures if they are entered into the input editor for further editing. The fields of expression templates display minimal formatting intended to hint at how such an expression would normally be typeset.
The Templates menu provides the following items:
- Derivative…
-
This template supports (partial) differentiation involving up to
three independent variables, each to arbitrary order. The orders
must be explicit positive integers and the total order
automatically updates to reflect the number of independent
variables and their orders. If an order is omitted then it
defaults to 1. At least one independent variable is required but
others are optional. The dependent variable defaults to
wsand the first independent variable defaults to x, but both can be changed. - Integral…
-
This template supports both indefinite and definite integration: if
both limits are omitted then the integral is indefinite; if both
limits are specified then the integral is definite. The integrand
defaults to
wsand the integration variable defaults to x, but both can be changed. - By default, the template provides a single integral, but if you enter another integration variable in a box to the right of the primary integration variable then an additional integral appears wrapping the previous integral, thus supporting double and triple integrals. Matching ∫ and d symbol pairs have the same colour (blue, green or red) to facilitate adding limits to the right ∫ symbol.
- Limit…
- This template supports limits of (mostly) continuous functions (as opposed to sequences). By default, it computes a two-sided limit, which is appropriate if the function is continuous at the limit point. By clicking successively on the superscript box to the right of the limit point field you cycle through the limit from the right/above (indicated by a superscript +), the limit from the left/below (indicated by a superscript -), and the default two-sided limit. All fields are required.
- Sum or Product…
- This template supports repeated sums and products of sequences, i.e. functions of a discrete control variable that runs over a range of successive integers. You select whether to construct a sum or product by clicking on the appropriate toggle button, which defaults to a sum.
-
You can select whether the range is considered to be symbolic or numeric, which selects different algorithms.
Selecting the symbolic range option (the default) implies that you want a closed-form result, which is analogous
to evaluating an integral, and the upper or both limit values can be omitted, giving an indefinite sum or
product. Selecting the numeric range option implies explicitly adding or multiplying a finite sets of values
using a
forloop, and all field values are required. - Matrix…
- This template supports the creation of matrices up to 4 by 4. The elements can be any expressions. The (1,1) element is always in the top left-hand corner of the template. The width of the matrix, i.e. the maximum column index, is determined by the right-most non-empty element and the depth of the matrix, i.e. the maximum row index, is determined by the lowest non-empty element. Within the matrix so determined, empty elements default to zero, which is very convenient for entering diagonal, triangular or other sparse matrices. For example, entering a zero matrix only requires entering 0 as the bottom right-hand element.
- To enter a matrix with more than 4 rows or columns, you can enter as much as possible using the template, then click on the Edit button and extend the matrix in the input editor.
- Solve Equation(s)…
- This template supports solving one or several coupled algebraic equations. If no unknowns are specified then REDUCE solves for all those found. Unknowns must be kernels.
- Solve an ODE…
- This template supports solving a single ordinary differential equation (ODE), meaning an equation involving the derivative(s) of a single unknown dependent variable or function with respect to a single independent variable (or function). An ODE in the field labelled ODE is the only required input and it can be an expression, which is implicitly equated to zero. REDUCE can normally deduce the dependent variable or function, and the independent variable, but if necessary either or both can be specified in the fields labelled respectively Dep Var and Ind Var.
-
Derivatives with respect to the independent variable can be specified using prime notation, where a prime is
indicated by a single forward quote, provided the independent variable is explicitly specified. (This syntax is
not accepted directly by REDUCE.) For example,
y''can be used to denote d2y/dx2 provided the independent variable is explicitly specified to bex; it is converted to the standard REDUCE syntaxdf(y,x,2). - Initial, boundary or mixed conditions can be specified in the field labelled Conds, as either a sequence of equations separated by commas in the case of conditions applied at a single point (e.g. initial conditions) or a sequence of lists of equations separated by commas in the case of conditions applied at more than one point (e.g. boundary conditions), where each list of equations represents conditions imposed at one point.
-
ODE solving can be controlled by a number of optional switches that are off by default but can be turned on
locally using the check boxes at the bottom of the template. Hover over an option for a brief pop-up
description. These settings have no effect outside the current solution process, although the
algintoption corresponds to the standard REDUCEalgintswitch that controls the integrator. - For Statement…
-
This template supports the creation of
forstatements and is modelled on the diagram at the start of the section of the REDUCE manual headed "FOR Statements". You choose between iterating over a numerical range or a list by clicking on the appropriate toggle button, which then displays the appropriate template. You choose the action and thefor each … in/onoption via drop-down menus, which default to the most common choices. (Note that thefor each … onoption is only allowed in symbolic mode, but the template does not check this.) The field for the expression to be evaluated by theforstatement is on a separate line to allow it more space.
Functions Menu
The Functions menu facilitates access to some of the mathematical functions provided by REDUCE via dialogue boxes similar to those provided by the Templates menu. The function dialogues all provide hyperlinks to the key sections of the HTML version of the REDUCE Manual, which open in a new tab in your web browser. Hover over a function name to pop up a tooltip that gives a hint at its definition, which often uses linearized mathematical notation similar to LaTeX (but without any backslashes).
The function dialogue boxes provide a grid of function
templates. Click on the radio button to the left of the
function you want to use. The templates display the conventional
notation used for the functions but with editable text fields
holding the function arguments. The default arguments are
either ws, where this seems appropriate, or the
conventional variable names.
The Functions menu provides the following items:
- Exp, Log, Power, etc…
- This provides the exponential function, various logarithms, power and roots (surds or radicals), factorial and binomial coefficients, and the hypot, atan2 and atan2d functions. The latter automatically loads the TRIGD package.
- Gamma & Beta Functions, etc…
- This provides the Gamma, Beta, digamma, polygamma, normalized incomplete Gamma and Beta, and dilogarithm functions, Pochhammer's symbols, binomial coefficients and the Riemann zeta function.
- Integral Functions…
- This provides exponential, logarithmic, sine, cosine, hyperbolic sine and hyperbolic cosine integral functions, the error function and complementary error function, and the Fresnel sine and cosine integral functions.
- Airy & Bessel Functions, etc…
- This provides Airy functions of the first (Ai) and second (Bi) kind and their derivatives (Ai' and Bi'), the families of Bessel functions of the first (J) and second (Y) kind, modified Bessel functions of the first (I) and second (K) kind, and Hankel functions of the first and second kind.
- Struve & Kummer Functions, etc…
- This provides the families of Struve (H) and modified Struve (L) functions, Lommel functions of the first (s) and second (S) kind, Kummer M and U functions, Whittaker M and W functions, and spherical and solid harmonic (Y) functions. The latter two automatically load the SPECFN package.
- Classical Orthogonal Polynomials…
- This provides the families of Jacobi (P) and Ultraspherical or Gegenbauer (C) polynomials, Chebyshev polynomials of the first (T) and second (U) kind, Legendre (P) and associated Legendre polynomials, Laguerre (L) and generalized Legendre polynomials, and Hermite (H) polynomials. This dialogue automatically load the SPECFN package.
Help Menu
The Help menu provides the following items, which all open in a new browser tab:
- Web REDUCE User Guide
- This document.
- REDUCE Manual
- The HTML version of the REDUCE Manual.
- About Run-REDUCE
- Information about Web REDUCE, including its limitations.
Controlling Web REDUCE via the URL
Options can be combined in any order with any or no separators, provided they begin with "?", e.g.
/web-reduce/?mobile,noautorun.
-
If the main Web REDUCE page is opened with a query string containing
mobileappended to the URL, e.g./web-reduce/?mobile, then the mobile version of Web REDUCE is started in full window mode; see Desktop and Mobile Versions and View Menu. -
If the main Web REDUCE page is opened with a query string containing
debugappended to the URL, e.g./web-reduce/?debug, then input to and output from REDUCE is logged to the web browser's JavaScript console (by callingconsole.log()). This facility is intended for developers. -
If the main Web REDUCE page is opened with a query string containing
noautorunappended to the URL, e.g./web-reduce/?noautorun, then Web REDUCE is not automatically run. -
If the main Web REDUCE page is opened with a query string containing
spoofappended to the URL, e.g./web-reduce/?spoof, then Web REDUCE is not automatically run, but the menus are enabled as if REDUCE were running.