Hi,

I am writing a function to pick up a non-polynomial term in an
expression.
The way I plan to do it is to recursively match the pattern p*q+r, and
return the first non-polynomial p, q or r.

Though, when I use match(), it seems that it will produce non-
deterministic/random results.

For example, if I run the following script,

x0 = Symbol('x0')
x1 = Symbol('x1')

p = Wild('p', exclude=[0])
q = Wild('q', exclude=[0])
r = Wild('r')

y = exp(40*x0) - exp(-40*x1 + 40*x0)
print y.match(p*q+r)

It sometimes return
{q_: exp(40*x0), r_: -exp(-40*x1 + 40*x0), p_: 1} (desired)
but it sometimes return
{q_: exp(-40*x1 + 40*x0), r_: exp(40*x0), p_: -exp(-40*x0 +
40*x1)*exp(-40*x1 + 40*x0)}
which makes my code to enter an infinite loop.

And this seem to happen randomly...

Does anyone have any idea how match() works in sympy?
And suggestions on implementing the function to pick up a non-
polynomial term from an expression is welcomed.

Thanks!
Chenjie

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to sy...@googlegroups.com.
To unsubscribe from this group, send email to 
sympy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to