Comment #13 on issue 1336 by smi...@gmail.com: Arbitrary constant type
http://code.google.com/p/sympy/issues/detail?id=1336

I don't have a special combining symbol but I have a 'model' function that absorbs all constants except for a specified 'x'. Using it on the examples of the OP shows that they are all the same:

for ei in e:
...  print together(ei), model(together(ei),x)
...
2*x/(c1 + x**2) 2*x/(C0 + x**2)
2*x/(2*c1 + x**2) 2*x/(C0 + x**2)
2*x/(2*c1 + x**2) 2*x/(C0 + x**2)

Here are the docstring examples:


    >>> from sympy import model, exp
    >>> from sympy.abc import x, y, z
    >>> model(y + 3, x)
    C0
    >>> model(y + 3, x, 'k')
    k0
    >>> model(x + 3, x)
    x + 3
    >>> model(x + 3, x, numbers=True)
    C0 + x
    >>> model(-x + 3, x, numbers=True)
    C0 - x
    >>> model(x + 3*y, x)
    C0 + x
    >>> model(x + 3*y, x, 'x')
    x + x0
    >>> model(exp(x + 3), x)
    exp(x + 3)
    >>> model(y*exp(x + 3), x)
    C0*exp(x)
    >>> model(3*exp(y + x), x)
    C0*exp(x)

That last examples involving a power in a Mul are going to be the tricky ones since the __mul__ or __rmul__ routine would have be receiving the exp() term as one of the args in order to determine that a combined constant can be created. That being the case, I don't think an Absorber would be able to do such combinations except in a flatten routine.

see simplify.py in smichr branch csimp; see also the test suite which covers all lines of the routine.

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

Reply via email to