Firstly, there is no subexpression a*b
in your expression. Inside the call to log
in your unparsed input there appears a subterm c/b*a
. But in Maple's syntax that gets parsed to something mathematically equivalent to (c*a)/b
and not c/(b*a)
.
But your question contains other ambiguity. Let's consider a few examples:
restart;
expr1 := y = s + (a/b)*log(a+c/b*a);
c a
a ln(a + ---)
b
expr1 := y = s + -------------
b
expr2 := y = s + a*log(a+c/b*a)/b;
c a
a ln(a + ---)
b
expr2 := y = s + -------------
b
expr2 - expr1;
0 = 0
So the expr1
and expr2
are mathematically equivalent. Maple is even holding their structures the same, internally. (You can check that using both the lprint
and the dismantle
commands.)
So you appear to be asking for a/b
to be recognized in either, after parsing the input, even though that term does not appear indentically in the verbatim input (before parsing). That's not wrong, per se, but we'll need to know that it's part of your expectation. If a/b
is to be recognized as a candidate subpression of that value, regardless of whether it's entered like expr1
or expr2
, then that is a key detail. If that is not your desire then you will really have to justify how they could be distinguished from each other after parsing (since they may parse to the same thing, depending on what's occurred already in the Maple session!).
Also, how do you intend on handling something which is mathematically equivalent to (a*s)/(b)
? Do you want code that returns all possible arithmetic pairings, eg. a*s, a/b, s/b
? Or do you want just a*s
, or just a/b
, or just s/b
?
Now consider another example:
expr3 := a+c*a/b;
c a
expr3 := a + ---
b
normal(expr3);
a (b + c)
---------
b
Those are mathematically equivalent, though stored differently. Depending on your definition of acceptable "sub-expression" you may or may not want want a/b
, or c/b
, or b+c
, in your results.
I think that you'll probably need to resolve what precisely you want, in at least these three example's ambiguous situations above, before your question could be resolved sensibly.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…