the change of order of terms in children command in symbolic matlab

1 view (last 30 days)
In symbolic matlab, when the command " children" is used, there is a chance the order of children change every time the code is run. Consider the case as expr=(A+B+C)*(D+E+F) and assume the order of the terms is important. Does anyone have an idea how to fix this.
X=children(expr)
X(1)=AD
in another try, the answer could be X(1)=BD!
The reason of change of the order is that matlab is doing the multiplication in "expr" randomly (I guess!). Any help would be appreciated.

Answers (1)

Walter Roberson
Walter Roberson on 23 Mar 2017
Edited: Walter Roberson on 8 Apr 2017
Unfortunately the Symbolic toolbox does not document the order of operands. I have explored in the past how the actual order it uses can be pretty sensitive and difficult to describe in simple terms.
I have not personally observed inconsistencies in the order of terms within any one expression, but it would not surprise me. MuPAD has a lot of similarities to Maple, and Maple specifically documents that in some cases the order of terms for it depends upon the memory address that happens to get assigned to the parts. MuPAD (the symbolic engine) could be the same way.

Community Treasure Hunt

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

Start Hunting!