`def constantsimp(expr, independentsymbol, endnumber, startnumber=1,
symbolname='C'):` It is looking to absorb constants into the the
numbered symbols. proportional_form combines everything except x. I
suppose one could use a renumbering scheme to assign a numbered symbol
to all non-x symbols and then run it through constantsimp. hmmm - that
didn't occur to me earlier (more below).

```python
>>> constantsimp(x+C0+y,x,1) # I think this is a bug
C0 + x + y
```

```python
>>> proportional_form(x+C0+y,x)
C0 + x
```

For comparison purposes, I am defining a function that will call
constantsimp after replacing all non-x symbols with numbered symbols:

```python
>>> def proportional_form(eq,x,s=Symbol('C')):
...  eq=eq.subs([(sy, Symbol(s.name+str(i))) for i,sy in
enumerate(eq.atoms(Symbol)) if sy!=x])
...  return constantsimp(eq,x,5,symbolname=s.name)
...
>>> proportional_form(y + z, x)
C1
>>> proportional_form(Integral(x, (x, 1, 2)), x, C)
Integral(x, (x, 1, 2))
>>> # should have been C0 <==================== difference
...
>>> proportional_form(x**2*y*exp(x+z) + x*y + x*z, x, C)
C1*x + C2*x**2*exp(x)
>>> proportional_form(x**2*y*exp(x+z) + x*y + x*z, x, k)
k1*x + k2*x**2*exp(x)
>>> proportional_form(3 + y*x + x*z, x, C)
C1*x + 3
>>> # or 3->C0 <==============================trivial difference
...
>>> proportional_form(3 + y*x + x*z + x**2*z, x, C)
C1*x + C2*x**2 + 3
>>> proportional_form(x - y, x, C)
C1 + x
>>> proportional_form(-x + y, x, C)
C1 - x
>>> proportional_form(-2*x + y, x, C)
C1 - 2*x
>>> # or 2-> C0 <======================= ditto
```

Perhaps instead of adding another routine, a wrapper that does the
symbol replacement could be made and the few remaining bugs in
constantsimp sorted out.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to sympy@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