# Wolfram Function Repository

Instant-use add-on functions for the Wolfram Language

Function Repository Resource:

Sort symbolic expressions using assumptions

Contributed by:
Sjoerd Smit

ResourceFunction["SymbolicSort"][ attempts to sort | |

ResourceFunction["SymbolicSort"][ sorts by assuming that | |

ResourceFunction["SymbolicSort"][ carries out symbolic manipulations over the domain | |

The argument *vars* can be either a List or a single variable.

ResourceFunction["SymbolicSort"] uses Resolve and ForAll to determine if one expression is uniformly greater than another.

The default value for *assum* is $Assumptions.

The default domain is Reals.

If no definite ordering can be found, ResourceFunction["SymbolicSort"] remains unevaluated and raises a message. Use ResourceFunction["SymbolicSort"][*list*,*vars*,*assum*,*dom*,List] to force the function to return a List.

In the Graph produced by ResourceFunction["SymbolicSort"][…,Graph], undirected edges will be used to indicate that two expressions cannot be ordered. Directed edges will only be drawn between consecutively ordered elements. To calculate the Graph, all possible comparisons between all elements will be made, so this functionality can be slow for large lists.

A TimeConstraint (default 5) option value can be specified.

Sort expressions in *x* defined for real numbers:

In[1]:= |

Out[1]= |

Plot to illustrate that Exp[*x*] is always greater than *x*:

In[2]:= |

Out[2]= |

Use assumptions for sorting:

In[3]:= |

Out[3]= |

In[4]:= |

Out[4]= |

Sort expressions of a monotonic function applied to different variables:

In[5]:= |

Out[5]= |

If no definite order exists, a message will be raised and SymbolicSort remains unevaluated:

In[6]:= |

Out[6]= |

Use List as the last argument to force a result:

In[7]:= |

Out[7]= |

If not all expressions have a definite ordering, you can instead produce a Graph that shows the ordering relationships between the elements of the List:

In[8]:= |

Out[8]= |

In[9]:= |

Out[9]= |

The undirected edges between , *x* and *x*^{2} show that these expressions have no definite ordering.

A time constraint can be set for symbolic comparisons. If the time constraint is too low, no result will be found:

In[10]:= |

Out[10]= |

Sort the eigenvalues of a symbolic matrix:

In[11]:= |

Out[11]= |

- 1.0.0 – 14 October 2020

This work is licensed under a Creative Commons Attribution 4.0 International License