Hello

(1) -> f:=(y-m)*sqrt(x)/s

                +-+
        (y - m)\|x
   (1)  -----------
             s
                                                    Type: 
Expression(Integer)
(2) -> k_sx:= first kernels f

         +-+
   (2)  \|x
                                            Type: 
Kernel(Expression(Integer))
(3) -> subst (f,[k_sx],[e*s])

   (3)  e y - e m
                                                    Type: 
Expression(Integer)
(4) -> %::POLY INT

   (4)  e y - e m
                                                    Type: 
Polynomial(Integer)
(5) -> factor %

   (5)  e(y - m)
                                          Type: 
Factored(Polynomial(Integer))

Regards
Themos Tsikas

On Sunday, 30 September 2018 17:41:57 UTC+1, 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.
>
> Curiously, without sqrt a similar rule works as expected:
>
> substF := rule (('y-'m)*'x/'s == ('y-'m)*'e) 
>
> substF ((y-m)*x/s)
>
> gives e*y - e*m
>
> Can you explain what is the difference here and how to approach the goal 
> of substituting a subexpression with a symbol?
>
> Thanks,
>
> Slawomir
>
>
>

-- 
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.

Reply via email to