Trouble with the pattern matcher ...



On 9/12/2013 1:09 AM, David Scherfgen wrote:
> Hello,
>
> I've stumpled upon the following behavior:
>
> (%i1) matchdeclare(f, true);
>       defmatch(df_over_f, diff(f, x) / f);
>       defmatch(df_times_f, diff(f, x) * f);
>       df_over_f(cos(x) / sin(x));
>       df_times_f(cos(x) * sin(x));
> (%o1) done
> (%o2) df_over_f
> (%o3) df_times_f
> (%o4) [f=sin(x)]
> (%o5) false
>
> In other words:
> The pattern matcher correctly recognizes cos(x)/sin(x), but fails to 
> recognize cos(x)*sin(x) - the only difference being the operator.
just a guess, but  in sin(x)*cos(x), there are 2 ways of matching f.  
f=sin(x) and f=cos(x).
If the wrong choice is made, then the diff(f,x) will not match the other 
term.

If you want to find a way to detect if the derivative of one term 
exactly divides the other, you
have to sequence through all the terms, or do something equivalent. The 
defmatch
mechanism does not do exhaustive search.


A paper which describes how to achieve what you want  (almost very 
explicitly your issue, I think) is

www.cs.berkeley.edu/~*fateman*/papers/partition.pdf


>
> It also fails for the very simple case of 1 and x:
>
> (%i2) df_over_f(1 / x);
>       df_times_f(1 * x);
> (%o6) [f=x]
> (%o7) false
>
> Am I doing something wrong here?
1*x is indistinguishable from x.  There is no "*" in it at all.

>
> Regards,
> David
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima