how to prevent reordering of terms by symbolic math functions

6 views (last 30 days)
When using symbolic math, terms are reordered. For example, a+s*b is changed to a+b*s. Is there a way to prevent this? Because sometimes results need to be stored as strings and their order has a special meaning and when order of terms are changed by symbolic math, it causes lots of other headaches.

Answers (1)

Walter Roberson
Walter Roberson on 18 Apr 2019
Yes, there is a way. You can create a whole bunch of MuPAD code to use the general framework of the internal symbolic engine in order to implement non-commutative objects and associated :print slots, and you would create a number of MATLAB level functions that used feval(symengine) or evalin(symengine) to create appropriate wrappers at the MATLAB level.
The amount of work involved would depend upon what operations you needed. For example if you needed to implement differential equation solving on your non-commutative objects involving hypergeometric functions, then it could end up taking a fair bit of effort.
It would sort of be like implementing a new arithmetic class in MATLAB that for arcane reasons all had to be implemented by string manipulation, with only a depressed debugger to help you.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!