Basic Examples (1)
Order three symbolic expressions involving the variables a and b:
Scope (2)
The expressions can contain constants:
Restrict the domain of permissible solutions:
Options (10)
Pattern (2)
Determine the conditions under which a−b will lie in the middle of the two other values:
Determine the conditions under which the ordering of a four-element list with respect to an operation will have its fourth member first and its second member third:
PatternInterpreter (2)
By setting the "PatternRepresentation" option, you can change the interpretation of the value of the "Pattern" option. For a value f taken by this option, and a value explist of the expressions to be sorted, the value of the "Pattern" option pat is interpreted as f[explist][pat]. Interpret the value of the "Pattern" option as indices into the list of expressions:
Use integer indices to represent a desired ordering but also permit blank patterns where one does not care about the exact ordering:
KeyFunction (2)
Represent the keys not as the expressions themselves but by indices into the original expression list:
Any arbitrary expression can be used as a "KeyFunction":
The default value for "KeyFunction" is Identity:
One can combine the "KeyFunction" option with the "Pattern" and "PatternInterpretation" functions:
AdditionalConstraint (4)
Place additional constraints on the expressions to be sorted:
The additional constraints can be geometric:
The additional constraints can result from the computation of an ImplicitRegion:
The additional constraints can result from the computation of a ParametricRegion:
All the options for Reduce are also supported, including user-specified generated parameters and display of full cubic and quartic expressions instead of root objects. The GeneratedParameters option works:
The Quartics option works (as does Cubics):
The WorkingPrecision option can be used:
Applications (2)
Show conditions under which a-b will have the smallest value among {a+b,a−b,a b}, but also requiring a+b<3:
In a three-party race, the first candidate has 20 votes, the second candidate has 25 votes, and the third candidate has 27 votes. It is estimated, however, that only 70% of the votes have been counted. Compute the conditions under which candidate 1 will end up with the most votes:
Plot the corresponding region:
Do the same computation but assume that to avoid a runoff election, candidate 1 must get more than 50% of the total votes:
Plot the resulting region:
Possible Issues (3)
The "Modulus" option cannot be used if the op argument generates an inequality:
As the length of the expression list grows or the length of the vars argument grows, the time needed to do the computations can grow significantly:
If Reduce cannot determine the order of the expressions, the computation can take a long time:
Neat Examples (3)
Under the original Article II of the United States Constitution and prior to the enactment of the Twelfth Amendment, the presidential candidate with the most votes in the electoral college would become the President of the United States and the candidate with the second-most votes would become the Vice President, even if the President and Vice President had serious disagreements. Suppose the electoral college votes of four candidates subject to that voting system depend on two parameters, x and y. Compute the conditions for each ordering of the four candidates:
Plot the regions of x and y for which each candidate becomes President and Vice President:
Compute the probability that each candidate will become President and Vice President, assuming that x and y are drawn from a multivariate normal distribution: