Slawomir Kolodynski wrote:
>
> Suppose I have an expression like *(y-m)*sqrt(x)/s* . What I would like to
> do is to give a name *e* to the *sqrt(x)/s* part and do some kind of
> transformation on this expression so that I get *(y-m)*e *or equivalent as
> the result*. *To do that I define a rule
>
> substE := rule (('y-'m)*sqrt('x)/'s == ('y-'m)*'e)
>
> However, when I try to apply this rule to the expression
>
> substE (y-m)*sqrt(x)/s
>
> I get the *(y-m)*sqrt(x)/s *expression back instead of *(y-m)*e. *It looks
> like the left hand side of the equality in the rule substE does not pattern
> match itself.
Yes. In expression numerator is a sum, that is what you really
have is:
y*sqrt(x) - m*sqrt(x)
In pattern (to which left hand side of the rule is converted) we
have product. Product does not match sum... I need to check
is this is just a bug or an unavoidable misfeature.
BTW: In your other example both pattern and expression is a sum
so the pattern matches.
Concerning your general question: in FriCAS expression is a
quotient of polynomials in kernels. Operations that identify
a useful subexpression usually can also identify complementary
part. For example, if your subexpression is denominator, then
numerator gives complement. If your subepression is a single
term of polynomial, than subtracting this term gives complement.
If your subexpression is a single factor of a term, than
complenent is product of other terms.
Internally FriCAS make only little use of pattern matcher.
Instead, various routines analyze structure of expressions
using lower level operations.
One consequence of internal representation used by FriCAS
is that frequently pattern needed to match given expression
is different than user input would suggest. This make
pattern matching somewhat unreliable (and that is why
FriCAS normally uses other approches). But of course
expression should match to itself...
--
Waldek Hebisch
--
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.