A computer algebra user interface manifesto
Abstract
Many computer algebra systems have more than 1000 builtin functions, making expertise difficult. Using mock dialog boxes, this article describes a proposed interactive generalpurpose wizard for organizing optional transformations and allowing easy fine grain control over the form of the result – even by amateurs. This wizard integrates ideas including:
flexible subexpression selection;
complete control over the ordering of variables and commutative operands, with wellchosen defaults;
interleaving the choice of successively less main variables with applicable function choices to provide detailed control without incurring a combinatorial number of applicable alternatives at any one level;
quick applicability tests to reduce the listing of inapplicable transformations;
using an organizing principle to order the alternatives in a helpful manner;
labeling quicklycomputed alternatives in dialog boxes with a preview of their results, using ellipsis elisions if necessary or helpful;
allowing the user to retreat from a sequence of choices to explore other branches of the tree of alternatives – or to return quickly to branches already visited;
allowing the user to accumulate more than one of the alternative forms;
integrating direct manipulation into the wizard; and
supporting not only the usual inputresult pair mode, but also the useful alternative derivational and in situ replacement modes in a unified window.
1 Introduction
“Before the Lisp machine interface to Macsyma,
computer algebra was like doing mathematics encumbered by boxing gloves.”
– Bill Gosper
I am sorry Bill, but that user interface from 1988 [18] disappeared with the Lisp machine, and its best features regrettably have not yet been implemented in any of the current most powerful computer algebra systems. Even the much earlier 1972 article [6] discusses desirable features that are still missing from modern systems.
Many computer algebra systems have more than 1000 builtin functions. Besides standard mathematical functions such as and classic higher transcendental functions, builtin functions often include numerous optional transformation functions such as , , , , and that supplement default simplification with various transformations. Besides the expression being transformed, these transformational functions often accept optional extra arguments such as a list of variables, and/or various keyword arguments that control details such as the amount of factoring. Moreover, most computer algebra systems have numerous global control variables whose values help control transformations done by these functions and/or by default.
Unlike , the names and semantic details of these transformation functions and control variables are not part of any standard mathematics curriculum. Therefore it requires a long time to fully exploit such systems well, and most users never do. Moreover, these names and behaviors vary greatly between systems, making it challenging to become skilled with more than one system in order to exploit their differing capabilities. Consequently many users are frustrated because they don’t know how to make any system transform an expression to a desired form.
Worse yet, often there is no composition of functions and/or or combination of controlvariable settings capable of producing a desired form. For example, users often want expansion with respect to a certain proper subset of the variables, with polynomial coefficients that are factored with respect to the other variables – or want partial fractions with respect to a certain proper subset of some variables, with factored numerators and denominators.
This article address the usefulness of computer algebra systems as productivity tools to help amateur users accomplish their tasks without necessarily being aware of the underlying algorithms, transformation functions and their nomenclature. This article presents some ideas for enhancing the kind of wizard implemented on the Lisp Machine by:

more flexible subexpression selection;

complete control over the ordering of variables and commutative operands, with wellchosen defaults;

interleaving the choice of successively less main variables with applicable function choices to provide detailed control without incurring a combinatorial number of applicable alternatives at any one level;

quick applicability tests to reduce the listing of inapplicable transformations;

using an organizing principle to order the alternatives in a helpful manner;

labeling quicklycomputed alternatives in dialog boxes with a preview of the result, using ellipsis elisions if necessary or helpful;

allowing the user to retreat from a sequence of choices to explore other branches of the tree of alternatives – or to return quickly to branches already visited;

allowing the user to accumulate more than one of the alternative forms;

integrating direct manipulation into the wizard; and

supporting not only the usual inputresult mode, but also the useful alternative derivational and in situ replacement modes in a unified window.
Section 2 describes important features to combine in a user interface. Section 3 presents some mock examples of using the proposed wizard. Section 4 addresses design issues and their resolution, with a summary in Section 5. The Appendix summarizes some important rationalexpression transformations that should be included in addition to those discussed in subsection 4.3. The wizard must also be aware of all of the many transformations specific to irrational expressions that are built in or should be, but that is an openended topic too large for discussion here. However, the wizard should be implemented in an extensible way that allows users to add components easily at run time for new transformations that they implement.
This article often uses “Float” as an abbreviation for “floatingpoint number”.
2 Important features to combine in a user interface
Many of the ideas in this section have been implemented to some extent in various computer algebra systems, but integrating them into a uniformly designed user interface could greatly enhance the user experience over that of any one current system.
Computer algebra often generates large expressions, and with current RAM sizes measured in gigabytes, screen area is now the most precious resource for most user’s tasks.^{1}^{1}1The maximum number of characters simultaneously legible on multiple highresolution screens or sheets of paper is unimprovable. Many of the ideas discussed here are concerned with attempting to make the best use of that limited resource to help amateur and expert users arrive quickly at the most comprehensible alternative output forms.
2.1 Enhancing the Lisp Machine Macsyma precedent
Among the most helpful features of Lisp Machine Macsyma was that as you moved the mouse over an expression, the minimal rectangle containing a syntactically complete subexpression surrounding the mouse pointer would automatically be framed, which is perhaps the entire expression. A right click would open a dropdown menu of common transformations such as factor and expand, or you could enter a function name of your own. The selected transformation is applied to the framed subexpression.
This feature could be regarded as a wizard that helped users quickly locate appropriate subexpressions for desired transformations, then apply them to those subexpressions. This is important because without subexpression selection and shortcuts for applying a desired transformations to selected subexpressions, it is painful for even expert users to force large expressions into anything near the form they would prefer – death by a thousand cuts and pastes.
Part of the pain is carefully reassembling a final result from independently transformed subexpressions, then carefully deleting the distracting debris of all the intermediate steps.
Even merely ordering commutative operands as desired is difficult or impractical in most computer algebra systems. For example, it is a constant irritant to be unable to transform a result such as to or, better yet, to prearrange that it will automatically be ordered as desired.
2.2 Qualitative analysis
There is a computer algebra package that does qualitative analysis, such as automatically determining whether an expression is monotonic, convex, periodic, or has odd or even symmetry with respect to each variable [28]. Such properties are often of greater interest than any particular form of the expression. Therefore the right click should also offer a qualitative properties option.
2.3 Including direct manipulation
Direct manipulation provides a complementary way that major computer algebra systems could make their user interfaces more helpful: With Milo [2] or Theorist [7] you could use the mouse to select a term or a factor, then drag and drop it to

reorder terms and factors,

distribute a term over a factor,

factor out a common factor from a sum of terms,

transpose factors or terms from one side of an equation to the other.
The selected subexpression could also be dropped into a variable in another expression to substitute the subexpression for every instance of the variable in that other expression. Also, expressions could optionally be compressed by automatic or mousedriven temporary replacement of subexpressions with ellipses. For example, here is a temporal sequence of Milo snapshots for dragging successively further right in an equation [16]:
Milo evolved to The Plotting Calculator, which is still available and supported [3]. The most recent version of Theorist is named LiveMath^{tm}, which is also still available and supported [19]. Both are oriented toward mathematics through calculus, but direct manipulation should also be implemented in other computer algebra systems, integrated with the transformation wizard proposed here: After selecting subexpressions, one of the transformation options, if applicable, should be “drag and drop”.
2.4 Collecting multiple alternatives
The wizard generates and displays the results of alternative transformations as the user explores a tree of successive applicable transformations. The user can accumulate any number of these alternative results into a list that is returned as the result if the user wants more than one alternative. For example, as users interactively view alternative factored and partial fraction forms for a rational expression, they can indicate which ones they want included in a returned list of alternatives. This is inspired by WolframAlpha [40], which automatically returns multiple alternative results. The difference here is that the user can participate in a more thorough exploration of the possible alternatives and select only those of interest.
2.5 Inputresult pairs versus derivation steps versus replacement
Most industrialstrength computer algebra systems use only the inputresult mode. This mode is particularly appropriate when the goal is to obtain good final results in as few steps as is practical.
Some mathematics education programs such as Mathpert^{tm} and the SMG application for some TI computer algebra products use the derivation mode wherein the input is transformed to a result by selecting successive subexpressions and choosing transformations from menus, with the annotated result of each step displayed beginning on a separate line. This mode is also often used in theorem proving software [31, 39]. This mode is also good for expository use by professionals when they want to explain in a presentation or publication how a result is derived. For example, the multistep derivational style is used several times in this article.
Some programs such as The Graphing Calculator offer the replacement mode wherein selected transformations replace the selected subexpressions in situ. This mode has the advantage of conserving screen space by minimizing the amount of debris – at the expense of not being able to view the input and result simultaneously.
An industrialstrength computeralgebra system should offer all three modes. The following observations can justify allowing mixtures of all three modes in a single session window and namespace context:

An inputresult pair can be regarded as a onestep instance of the derivation mode.

A one step in situ replacement could be labeled with a twobutton setter bar such as
that toggles between the two. 
A multistep in situ replacement could have a slider bar between these two endpoints, and perhaps also a Play button that does a slide show or an animation.

A right click could offer the option of changing previous computations between these three modes, such as

collapsing a derivation sequence to an inputresult pair or to an in situ replacement,

expanding an inputresult pair to a refinable derivation sequence that was automatically used to create it.

The modelviewcontroller paradigm is a good way to achieve this multiview software design [38].
2.6 {Undo, redo}
Anyone who has used software with a well designed essentially unlimited undoredo capability knows how aggravating it is to return to software that offers only one step of undo – perhaps with no redo. With current RAM capacities measured in gigabytes there is no excuse for this. Internet browsing has familiarized users with using the “” and “” buttons together with a dropdown browse history list to revisit easily throughout the tree of past web page visitations. The wizard can use the same techniques and temporarily save all recent closed dialog boxes for quick regeneration.
2.7 Dynamically created dialog boxes specialized for the example
The variety of mathematics examples is so great that generalpurpose dialog boxes created when a computer algebra system is built would be unpleasantly cumbersome to use:

They would have numerous distracting grayedout controls.

They would entail numerous subsidiary dialog boxes to accommodate all of the inapplicable entries without making each dialog box unreasonably large.

They would contain lengthy or awkward wording such as “variable or variables” or “variable(s)” to correctly accommodate both singular and plural cases without distracting grammatical errors.
Thus custom dialog boxes specialized to the framed subexpression must be created at run time.
2.8 Adapt to the user’s level and goals
Computer algebra is being used by students from beginning secondary school algebra through graduatelevel mathematics – and by professional mathematicians, scientists, engineers, economists etc. at many different levels of sophistication. The number of potential users declines rapidly with increasing mathematics level. However, most computer algebra systems are designed for the higher levels of this spectrum. Consequently the most powerful generalpurpose systems are quite daunting to most potential users. For example, in many courses from secondary school algebra through university realvariable calculus:

Many students know nothing about hyperbolic functions, higher transcendental functions and hypergeometric functions.

Most students have not encountered many standard mathematics symbols and notations such as , , , , , , , and .

Most students know nothing about terminology such as algebraic groups, rings, fields, ideals, varieties, and squarefree factorization.

The expression is usually or always regarded as undefined rather than as or a circle of infinite radius in the complex plane.

The expression is usually or always regarded as undefined rather than .

The expression is usually taken to mean rather than .
The mathematically weakest students and professionals who could most benefit from computer algebra are most intimidated by the appearance of such unknown function names, symbols and nomenclature in their dialog boxes and results. Often this intimidation and the consequent loss of self esteem terminates receptivity to learning effective use of the computer algebra system.
In computer aided instruction there are efforts to automatically infer the level and overall goals of users, then adapt the interface accordingly. Those techniques are not explored in this article, and the termination of receptivity might occur before enough input occurs to make an accurate inference. However, one easy way to accomplish many of the benefits of such customization is for the first dialog box of a session to have a button labeled “Session preferences” that opens a dialog such as the following if pressed:
The defaults should be those of the computer algebra system, but the more elementary alternatives should appear first in each row of alternatives to minimize alarming elementary users.
Another complementary alternative to matching student mathematical level is to enable the easy creation of named shell programs and their icons that launch the computer algebra system then immediately set appropriate preferences automatically. An instructor can then create such shells named, for example, MapleForAlgebra1 or MathematicaForCalculus1.
3 Examples of using the wizard
This section contains examples of using the proposed wizard.
3.1 Simplifying an ugly expression
The Mathematica function is a convenient way to create new dialog boxes at run time. Thus I used to create dialog boxes that are appropriate for specific examples, without bothering to attach these boxes to each other or to any Mathematica transformation functions. The mock intermediate and final results are not that of any particular current computer algebra system, but rather what I wish they would produce – especially with regard to ordering of factors and terms. For example, suppose that either an input or a result of previous steps is
(1) 
I have no particular goal form in mind, but I would like a result that is more concise and comprehensible – and more efficient for substitution of numbers. I position the mouse pointer between the left margin and the expression, thus framing the entire expression, then right click and choose the “qualitative properties” option, which determines that the function defined by this expression has the permutational symmetry . This was determined by simplifying to 0. (None of the differences for the other transpositions of two variables yielded a difference of 0.)
I then right click again and choose “transform”.^{2}^{2}2Alternatively, I can choose “Transform …” from the main menu bar or click Transform on the main toolbar. This opens the following dialog box courteously positioned just above the subexpression if the subexpression is low on the screen, or just below the subexpression otherwise^{3}^{3}3I hate it when a dialog box initially covers the information I need to respond to it! :
Some transformations such as expansion of an improper ratio to a polynomial plus a proper ratio require a designated variable. The None button considers only transformations that do not require such a variable, such as factoring or polynomial expansion with respect to all variables. With that choice, the variables would be ordered according to the analysis in [20].
The variables are listed in nonincreasing order of an estimated number of applicable common transformations because the choice of main variable tends to have the greatest influence on the overall form of the result. Choosing a main variable for which there are few alternative forms tends to narrow the choices more than otherwise. For example, if we chose , , or as the main variable, then there would probably be fewer than 5 common alternatives for thereafter. Thus button was initialized to pressed to encourage lazy users such as me to accept it, which I do. This opens the following dialog box:
“A lot of times, people don’t know what they want until you show it to them.”
– Steve Jobs
The Advanced button lists alternatives that would interest most users only occasionally for this example – alternatives such as continued fractions, Hornerization, expression in terms of Chebyshev polynomials, or series approximations.
The displayed sizes are some easily computed measure that correlates approximately with the relative area that would be required to display the entire alternative results. The initially checked boxes are those having the smallest size.
The dialog box initially shows alternative results for all the alternatives that can be computed in a total of at most 0.1 seconds – with elisions if necessary to avoid scroll bars or using the entire screen. User interface designers [24] feel that maximum acceptable response times are:

about 0.1 seconds for responses to a mouse click, key press, or anything involving handeye coordination;

about 1 second for opening a progress indicator, closing a dialog box or reformatting a table;

about 10 seconds for everything else, including displaying a graph or completing an understandably timeconsuming task. This “mind begins to wander” threshold is not always achievable with computer algebra.
The Mathematica , ,
,
and
functions require a total of only 0.04 seconds on a dualcore 1.6
gigahertz computer to compute Mathematicaordered versions
of the five initiallydisplayed results in this dialog box. Therefore
this dialog box could be created and displayed in an acceptable amount
of time.
The progress bar for the alternative appears within one second, indicating that it is still being computed after the initial display of the dialog box. If that function doesn’t post progress messages, then a slug cyclically moves from left to right to let the user know that the computer is working rather than merely awaiting user input.^{4}^{4}4It is not yet customary to have computer algebra functions post progress messages, but there are obvious candidate events for some algorithms. For example, many algorithms for degree or for variables, terms, factors, equations or columns process them one at a time, permitting messages of the form “ % done”, “ % done”, … even if the time spent for each such step is likely to be rather uneven. People are comforted by progress bars even when they are inaccurate. The alternative represents the system’s most powerful generalpurpose simplification function such as the Mathematica function, which requires 2.4 seconds for this example. This is much less than the time it requires for me to compare the five alternatives above with the Framed expression. As such continuing computations complete, their results are displayed in the dialog box – partially elided if necessary. They are listed below initiallypresented results to reduce displacement distraction when they complete. The alternative completes with a size of 125, which is the smallest, so that check box also becomes checked if I haven’t already pushed a button.
Every time a check box is checked that has not been checked before, if the corresponding result is partially elided, then another dialog box opens that merely displays the unelided alternative result, with scroll bars if necessary. For example, the initial “Polynomial + proper fraction wrt r” choice opens the dialog box
and when completes, it opens the dialog box
Both alternatives are significant improvements over the original framed expression (1), but both numerators are still lengthy with no easily discerned pattern. The reasons for the factored denominator in “Polynomial + proper fraction” are:

The factored denominator was already computed for the alternative “Factored with respect to ”.

The factored denominator is much more compact and informative than the fully expanded original denominator.

There is nothing in the phrase “Polynomial + partial fraction” that promises displaying the denominator expanded with respect to that was used to compute the polynomial part and the numerator.

It is easy to frame the factored denominator then expand it if desired.
Although the ConciseForm result is slightly more compact, perhaps I could improve the numerator of the proper fraction result because I requested no more than a polynomial plus a proper fraction, and the quickest path to that goal was to expend no extra effort on the numerator beyond the collection with respect to the main variable that was already done. Therefore in either the dialog box that contains the elided or the complete version of the proper fraction, I frame the entire numerator, right click, then choose “transform”. This recursively opens up a new dialog box to choose a main variable, for which I again choose for consistency. The resulting displayed alternatives include the factored numerator
This is much more compact, with insightful symmetries , and that are also true of the denominator. Therefore I accept this replacement in this subproblem that is an alteration of the “Polynomial + proper fraction” alternative, thus transforming the expression in that dialog box to
(2) 
This is the nicest overall result so far, but before accepting it, I notice that although every factor contains , the first numerator factor and the first two denominator factors are free of and , whereas the second numerator factor and the last two denominator factors are free of and . From experience I know that for two ratios having disjoint variable sets or nearly so, common denominators almost always increase bulk because there can be very little cancellation in the resulting numerator. Thus conversely, partitioning the ratio in (2) into a ratio containing and a ratio containing then transforming each ratio to partial fractions might reduce bulk. Consequently, I drag the first numerator factor left of the ratio giving
Then I drag the first two denominator factors under the former numerator factor giving
(3) 
(With the ability to select several nonadjacent subexpressions, I could instead select in (2) the first factor of the numerator and the first two factors of the denominator, then right click, then choose an action named something such as “collect”, “group” or “isolate” – or perhaps directly choose partial fractions.)
Next I highlight the left ratio in (3), choose as the main variable, then accept partial fraction expansion with respect to , then do similarly for the right factor, giving
(4) 
This is a very gratifying result compared to the equivalent input (1), and I am happy with the ordering of the terms and factors. Therefore I press the Accept result button, which opens the dialog
If I choose “New InputResult pair”, then the main computer algebra session window would be updated with a numbered input such as followed by expression (4) preceded by a label such as . The purpose of the Input line is to capture a programmatic way to transform to for purposes such as scripting. Most users will not want to view the ugly details, but if I click on the ellipsis in , then it expands to a procedure that generates , such as
The “New derivation sequence” choice is similar, except it generates a collapsible sequence of such pairs using labels such as , , … .
The “New InputResult toggle” is similar to the “New derivation sequence”, except listing a single expression labeled with a twobutton setter bar.
3.2 Transforming equations, inequalities and Boolean expressions
The primary activity that users want to do with equations, inequalities and systems thereof is to transform them into explicit solutions, so why force users to learn numerous different function names with different parameter semantics for solving different kinds of equations and inequalities? If the user clicks the Transform button when an entire equation, inequality or system thereof is framed, then the wizard tries to return solutions. Here is an example for a differential equation:
Notice the synergy of multiple views of the solutions. When the mouse pointer is over a curve, it is attached to a callout displaying the corresponding explicit solution containing the associated numeric value for . The plot range for and the set of values for were chosen to insure that is real. Checking this alternative opens a dialog with a magnified plot that gives the user control over the plot ranges for and together with the set of numeric values for . The listed size of 308 is correlated with the area of the plot in the session window if accepted.
Here is an example for a system of two nonlinear algebraic equations:

The approximate solution was computed with adaptive precision interval arithmetic to deliver guaranteed requested accuracy initially set to correspond to six significant digits for nonzero components. If interval arithmetic is inapplicable or is taking too long for the specified accuracy, then the wizard tries adaptive significance arithmetic. If that is also taking too long, the wizard switches the popup digits setting to “IEEE” double and uses that. The corresponding displayed phrases are “Estimated correct fractional digits” or “Approximate solutions of unknown accuracy” respectively.

The triangularized system is a reduced lexicographic Gröbner basis, which might be the preferred alternative for parametrized systems having exact explicit solutions that are messy or require unendurable time to complete. If the system included inequalities, then there would be a cylindrical algebraic decomposition instead.

The and ranges in the plot were automatically set to include a margin around the convex hull of all the isolated finite solutions – a margin small enough to resolve detail near the solutions but large enough to provide useful context.
Here is an example of transforming a Boolean expression:
The Advanced button lists alternatives expressed in terms of nands, nors, etc.
3.3 The wizard is helpful even for mere numbers
Common useful internal representations for exact numbers are rational numbers and irrational constant expressions such as . Common representations for approximate numbers are:

software variableprecision Floats – preferably with adaptive significance tracking,

IEEE double Floats to take advantage of fast hardware instructions;

intervals whose endpoints are each independently an exact rational number or a Float – preferably adaptive precision for floatingpoint endpoints, and allowing a disjoint union of such intervals with either open or closed endpoints.
Before commencing a computation a user might want to transform from an exact to an approximate representation to make the computation faster – or from an approximate to an exact representation to avoid rounding errors. After a computation a user might want to convert from an approximate to an exact representation to attempt recovering an exact result – or from an exact to an approximate representation to make lengthy exact numbers more comprehensible or faster for purposes such as plotting. Also, at the end of a computation a user might want to simply alter the display of a number, such as displaying an exact rational number factored or as an integer plus a proper fraction or as a decimal fraction or in scientific form with a particular number of fractional or significant digits. The wizard makes it easy to do these transformations.
3.3.1 Alternate forms for rational numbers
If the framed subexpression is
then the wizard could offer the dialog box
In accordance with the recommendations of [29], the approximate alternatives are ordered from intervals through bare IEEE Floats to encourage more use of arithmetic that is closer in spirit to exact arithmetic. The Advanced button could offer adic, continued fraction, and different radix representations.^{5}^{5}5In most systems, default simplification would immediately transform a factored or continued fraction or integer plus proper fraction form of a rational number back to a reduced ratio. Thus special passivity is required to make such volatile forms appear in results, and such nonidempotent forms are quite likely to disappear when such results are used in subsequent inputs. For this reason, many systems return a factored rational number as a list of pairs of bases and exponents, etc. The wizard must correct for such impediments to direct substitution of transformed subexpressions into the expression from which it came, suppressing default simplification where necessary to preserve the displayed overall result in standard mathematical form.
Notice that this dialog provides useful supplementary information about the framed number even if the user never intended to replace the framed number: The user now has a good estimate for its magnitude, can see that it is well approximated by , and that both the numerator and denominator are composite but square free.
3.3.2 Alternate forms for intervals and Floats
If the framed subexpression is an interval, an IEEE double or a variableprecision Float, then the wizard could offer alternatives including approximating the number with an exact rational or irrational constant. For example, if the framed number was the IEEE double 7.024814731040727 or a reasonably close approximation to it, albeit perhaps displayed with fewer significant digits, then the wizard could offer
Details matter. For example:

The alternate expressions are aligned, if practical, to make it easier to compare them.

If the framed Float displayed few digits, the initial displayed digits for alternatives displays all or many digits – and vice versa.
The delightful alternative was computed quickly by the Maple function, for which there is a more powerful free standalone version on the internet [5].
3.3.3 Alternate forms for nonreal numbers
For nonreal numbers, which of rectangular, unit polar and exponential polar form is most attractive depends on the particular number. For example, compare
Default simplification would ideally display the form that is most concise for each nonreal number in a result even if a different form is used internally. However, optional transformations can conveniently offer all three alternatives.
4 Design issues and their resolutions
Challenging design issues include deciding:

What set of transformations should the wizard consider?

How can the wizard quickly estimate the number of applicable transformations without knowing the next variable choice?

When the next variable choice is known or None, how can the wizard quickly determine what subset of transformations are applicable and schedule them so that a worthwhile number are completed quickly?
This section addresses these issues and a few others. However, there are so many transformations that the wizard should know about that this section concentrates on those that help resolve issues 2 and 3. For more completeness, the Appendix discusses additional transformations that are relevant to the rational aspects of expressions. Transformations of the irrational aspects of expressions is too large a topic for treatment in this article.
First, three simple definitions:
Definition.
Default simplification is the result of pressing the Enter key or else perhaps Shift Enter with the factorydefault mode settings and no transformational or simplification functions anywhere in the input expression.
Definition.
A functional form is an expression of the form
where is any function name.
Definition.
Generalized variables are the smallest subtrees of an expression tree that are not a sum, difference, product, ratio, rational number, Float, or reasonably regardable as an integer power.
For example, , , , , , and are generalized variables. In contrast, 3/4, , and are not. Also, and are not generalized variables, because they can be regarded as and
The importance of generalized variables is that transformations that
are applicable with respect to variables in an expression can also
be applicable with respect to generalized variables in an expression.
For example, a user might want ordering, expansion or factoring with
respect to to and or . Additional transformations
might be applicable with respect to generalized variables that are
not merely indeterminates, such as ,
, or .
As a prerequisite to discussing the wizard, it is helpful to organize the most important optional transformations offered by most computer algebra systems into categories of related transformations. For simplicity, the discussion addresses only constant ground domains that are common scalar numeric domains of characteristic 0. However, much of the discussion is relevant to other ground domains such as or .
4.1 Different transformations for different generalized variables
“To each his own.”
– Cicero
“I got different strokes for different folks.”
– Muhammad Ali
Often users want certain transformations such as expansion or factoring only with respect to certain variables. For example:

To compute the integral of with respect to , it is helpful to expand with respect to , but foolish to expand with respect to .

To solve
it is helpful to factor with respect to , but foolish to factor with respect to .
In these cases we would prefer either concise or mere default simplification with respect to .
When the user requests successive transformation for successive variables, we do not want to destroy transformations done for prior variables. Consequently, requested transformations are automatically mapped into the largest subexpressions that do not contain variables that have already been treated. For example:

If the alternative for expanding a framed expression with respect to the chosen main variable is
then factoring this alternative with respect to gives rather than

If the alternative for factoring a framed expression with respect to the chosen main variable is
then expanding this alternative with respect to gives

If the alternative for factoring a framed expression with respect to the chosen main variable is
then factoring this alternative with respect to gives
(Notice that the wizard factored not only the coefficients of powers of with respect to , including the coefficient of the zeroth power of , but also the toplevel content , because none of these contain .)

If the alternative for expanding a framed expression with respect to the chosen main variable is
then expanding this alternative with respect to gives two distinct alternatives: distributed form
and the often more concise recursive form
both of which are offered to the user. Expansion of will be offered if the user proceeds to that last remaining variable rather than balking or accepting an alternative already displayed.
Now consider the input . If the user is allowed to choose trigonometric expansion of multiple angles for the generalized variable but choose the opposite transformation for and , then this product can transform to the particularly concise equivalent because and .
Thus for maximum flexibility:

The user should be able to choose the order of generalized variables.

The user should be able to choose separate transformations for each generalized variable.

The choices for each variable should include and mere reordering with any associated default simplification when such results differ from the framed subexpression.

Where there is expansion with respect to two or more successive variables, both distributed and recursive forms should be offered if they are not identical.
4.2 Control over the order of generalized variables
“Order is the shape upon which beauty depends.”
– Pearl S. Buck
Subsection 4.1 discussed how collection of similar powers of a generalized variable can be recursively applied to the resulting collected coefficients to perform transformations for successive generalized variables in any order. However, current computer algebra systems would nonetheless impose their builtin ordering rules to the resulting factors and terms. Therefore the displayed ordering of factors in terms and of terms in multinomials might not correspond to the recursive most main to least main order in which the user has treated successive variables. For example after requesting expansion with respect to with coefficients that are factored with respect to all other variables a user might obtain a result such as
rather than the more appropriate result
Also, regardless of the requested order, output for Newton’s definition of force might be displayed as
(5) 
which is visually quite disturbing despite its compliance with the usual alphabetical ordering convention for variables in a monomial. Consequently:
Optional transformations should include control over the displayed ordering of factors and terms.
The few systems that give such control tend to do so indirectly and incompletely via control over the ordering of generalized variables. For example:

In the Maxima computer algebra system the desired order for result (5) can be accomplished by a declaration such as or . If the user has issued an and a nonconflicting declaration, then all other variables order between the least of the great and the greatest of the least, alphabetically. The effect is global from the time of a declaration until all declared orders are deleted with an declaration, which must be used between any two declarations or between any two declarations. Maxima also provides another mechanism for overriding default alphabetical ordering:
gives each variable the corresponding property. Possible properties include constant, scalar, and mainvar. The command can be used to remove such a declaration. Using to represent “less main”,
By default, alphabetical order is used within each of these categories.

The Reduce computer algebra system has an order declaration that is similar to , except that more than one cumulative order declaration is allowed before a declaration
which clears all such ordering declarations. The Reduce order declaration also accepts functional forms and builtin literal constants such as , which is important.

These and some other systems provide some control over the ordering of special distributed polynomials for Gröbner bases, but that is not very helpful for controlling the ordering of factors and terms in general expressions.
4.3 Common alternate forms for the rational aspect of expressions
Many computer algebra systems have separate functions for common denominators, various factorization levels, and various levels of polynomial or partial fractions expansions. This subsection describes how, for any particular ordering of generalized variables, these traditionally disparate concepts can be organized into a single topologically sorted list of partiallyordered alternatives varying from the most complete commonlynamed factorization through the most complete commonlynamed expansion offered by many computer algebra systems. This organizing principle greatly simplifies the transformation wizard by preventing selection of a set of contradictory transformations and by making the tradeoff consequences in this list more obvious.
This subsection concerns only addition, subtraction, multiplication, division and integer powers, but most of the ideas also apply recursively to rational compositions of generalized variables and to fractional powers. Moreover, this subsection discusses only factoring, common denominators and expansion because they are most relevant to estimating quickly how many transformations are applicable for each variable and for quickly determining exactly which common transformations are applicable for a particular variable. The Appendix discusses additional rational transformations.
4.3.1 Reasons for common denominators, factoring and expansion
Definition.
A candid expression is one that is not equivalent to an expression that visibly manifests a simpler expression class [25].
As counterexamples:

The expression is not candid because it contains the superfluous variable .

The expression is not candid because it appears to be quadratic but is actually linear.

The expression is not candid because it is equivalent to , which has lower numerator and denominator degrees.
Reduction over a common denominator yields a candid form for rational expressions, because the resulting form has no superfluous variables and has maximum possible cancellation of poles with coincident zeros. For most computer algebra systems, any amount of factoring includes reduction over a common denominator.
4.3.2 A univariate partiallyordered set of factorization and expansion levels

For univariate factoring there are names for certain amounts of exact or approximate factoring based on multiplicities and the desired numeric coefficient domain of the factors:

term primitive,^{6}^{6}6The term content of a univariate polynomial is the gcd of the numeric coefficients times the smallest occurring power of the variable. Factorization into the term content times the term primitive part forces a common denominator if any coefficient has a denominator, because with polynomials , , and , where .

square free,

over the integers ,

over the Gaussian integers ,

over particular algebraic extensions,^{7}^{7}7As a convenience in Mathematica, automatically uses extensions implied by the complex unit and/or any radicals present in . For example, However, because is not in the given polynomial. We must instead use to obtain this factorization, but how many users would know to include ?

exact reasonably absolute,^{8}^{8}8This is what is usually expected of algebra through calculus students for purposes such as solving equations or integrating rational functions: Algebraic extensions implied by radicals in the input together with use of the quadratic formula and ^{th} roots to factor binomials. Derive offers this option but also includes cubic and quartic formulas, which tends to generate unreasonably messy factorizations.

exact absolute,^{9}^{9}9This means whatever algebraic extension is necessary to factor the polynomial as much as possible, without the extension being provided by the user. Reference [9] discusses some algorithms for this. Some systems appear to use absolute factorization in their functions that solve systems of polynomial equations and integrate, but unfortunately appear not to offer it as a builtin factorization option. Therefore many computer algebra systems cannot directly factor into without assistance, which any beginning algebra student can do!. Attempted exact absolute factorization might consume an intolerable amount of computing time, or resulting factors might entail intolerably messy nested radicals or intolerably messy subexpressions containing functional forms named something such as Root. This is why I list the exact reasonably absolute level of factorization.

approximate absolute over the floatingpoint real numbers ,

approximate absolute over the floatingpoint complex numbers .^{10}^{10}10Alternatives (h) and (i) are approximations rather than equivalence transformations. Some methods for exact absolute factorization begin from an approximate absolute factorization that is often preferable to the resulting messy exact factorization!


For systems that support variable precision Floats, users can choose the precision level for alternatives (h) and (i). For systems that offer significance and/or interval arithmetic, those alternatives order immediately before (h) for real numbers and before (i) for nonreal numbers.

With denoting the fact that for a given example, a factorization at level is either identical to a factorization at level or is a further splitting of the factorization at level , we have
Thus these factorization levels form a directed acyclic graph. that we can topologically sort into one of several alternative lists, such as order 1(a) through 1(i) above.^{11}^{11}11Actually, different specific algebraic extensions generally form a directed acyclic subgraph because, for example, we could have any one, two or all three of the extensions , and , giving more than one path to These directed acyclic subgraphs are the field extension lattices of Galois theory.

If we fully expand the product of the numerator factors and the product of the denominator factors of a reduced ratio, then we have the reduced ratio of two fully expanded polynomials. Despite the common denominator, the result is an expanded polynomial when this reduced denominator is 1 or when both the numerator and denominator are numeric. Therefore this form is on the borderline between factored and expanded.

The computer algebra builtinto Texas Instruments hand held, Windows and Macintosh products has a function that expands into a expanded polynomial with respect to plus a reduced ratio of two polynomials that is proper with respect to . The function can easily be implemented using a polynomial quotient and remainder function, and the resulting form is an appropriate next node in our partial ordering from most factored to most expanded. This form is often more concise than either a common denominator or a partial fraction expansion. For example, this form was a key intermediate step in the example of subsection 3.1. For canonicality:

The coefficients of the resulting expanded univariate polynomial part that are not complex Floats can be normalized to Gaussian rationals or rationalized algebraic numbers.

The denominator of the proper ratio can be made unit normal as described in [26].

The numeric coefficients in the resulting proper ratio that are not complex Floats can be normalized to Gaussian integers or algebraic integers.

If all of the denominator numeric coefficients are complex Floats, then we can normalize their magnitudes – such as making the largest of the real and imaginary magnitudes in the denominator coefficients be 1.0.


Polynomial expansion can be regarded as a special case of for when the denominator of the given reduced ratio is numeric – perhaps 1.

If the reduced ratio of two polynomials has a nonnumeric denominator, then the relevant adjective phrases 1(a) through 1(i) above can be used to label successive nodes corresponding to the amount of denominator factorization for corresponding partial fraction expansions.

However, the squarefree aspect of partial fraction expansion has two variants in the partial ordering. In nondecreasing order of the amount of expansion, adjective phrases applicable to the square free aspect are:

incomplete, meaning multiples of all powers of the same squarefree denominator factor are combined over a common denominator, and

complete, meaning instead that for each resulting very proper ratio with expansion variable , .^{12}^{12}12In contrast, for the incomplete squarefree partial fraction expansion we can guarantee only that . Many systems offer only complete expansions, but incomplete expansions are adequate for most purposes and are often more concise!

Whenever a resulting numerator has more than one term, we can distribute an associated denominator over the numerator terms. It is generally unwise to distribute a multinomial denominator over the numerator terms for purposes such as integration, and it almost always increases bulk. However, it is helpful to do such a distribution for purposes such as fragmenting a ratio into the greatest number of simplest possible pieces for angle sum expansion.^{13}^{13}13If you must distribute multinomial denominators over numerator terms, it is most efficient to wait until after the expansion is complete in other respects. The wizard can display both alternatives when they are not identical.
Table 1 shows the named alternative forms for a univariate example of the reduced ratio of two expanded polynomials.

The first two rows and last two rows are approximations to all of the other rows, which are equivalent to each other.

The double line separating “ratio of expanded polynomials” and “polynomial + proper ratio” separates factored from expanded forms.

Factors that differ from those of the preceding row are boldface.

Wherever there is a sum in a numerator, the corresponding denominator can optionally be distributed over the terms of the numerator.

For each of these named levels an example can be constructed where it is more concise than all of the other named levels. Therefore all of the levels are important.^{14}^{14}14There are also unnamed intermediate levels such as splitting some but not all of the squarefree factors over .

If a system doesn’t offer builtin support for all of these named levels and a wizard implementer is not inclined to add such support, then:

Missing intermediate factorization levels can be provided by overfactoring then expanding appropriate subsets of factors.

Missing expansion levels can be provided by over expanding then combining appropriate subsets of summands.


The input could be any of these expressions or any rational expression that is equivalent to one of these expressions. If an input contains Floats, then floatfree alternatives can be obtained by using a function such as the Maple function to determine close rational or irrational constants [5].
Amount of factor or expand  Boldface parts are different from the alternative above them 

reasonably absolute ()  
square free  
term primitive  
ratio of expanded polynomials  
polynomial + proper ratio  
term primitive partial fraction  
incomplete square free part frac  
complete square free part frac  
partial fractions over  
partial fractions over  
absolute partial fractions  
partial fraction over  
partial fraction over 
4.3.3 Multivariate partiallyordered sets of factorization and expansion levels
References [22, 27] describes how to do multivariate partial fraction expansion with respect to two or more successive generalized variables. As a degenerate case, the expansion is polynomial expansion with respect to variables that don’t occur in the reduced common denominator of the given expression.
As shown that article, the number of terms in a multivariate partial fraction expansion can depend on the ordering of the expansion variables. Table 2 shows eight alternatives for factoring and or expanding a bivariate example over . Notice how the partial fraction expansion with respect to in the last two rows introduces poles at into some individual ratios, forcing the use of a piecewise result to avoid contracting the domain of definition. Making a ratio proper can also cause this. (Unfortunately, most current computer algebra systems quietly do such domain reductions.) Common denominators remove these additively removable singularities.
1^{st}  2^{nd}  Result 
