On Thu, Mar 15, 2012 at 9:59 AM, Aaron Meurer <[email protected]> wrote:

> Hi.
>
> I just created http://code.google.com/p/sympy/issues/detail?id=3148.
> The issue is related to constantsimp() in the ODE module.  Basically,
> right now, it converts things like 2*C1 + C1**2*x + (C1 + 1)*x**2 into
> C1 + C2*x + C3*x**2.  In other words, it absorbs C1, C2, ... constants
> into other constants and into each other, and then renumbers them,
> because they are no longer the same constant.
>
> I think this is a bad idea, because it makes it look like C1, C2, and
> C3 are independent of each other, when they really aren't (because, in
> this example, C2 = C1**2/4 and C3 = C1/4 + 1).  What I think it should
> do instead is return something like C1 + C1**2/2**2 + (C1/4 + 1)*x**2.
>  In other words, simplify one constant, and rewrite the others in
> terms of it.
>
>
What is simpler about that, though? Now you have C1/4 where before you had
2*C1.

<work below comes from my model branch which was pull request 598>

    >>> var('C:4')
    (C0, C1, C2, C3)
    >>> condense(S('2*C1 + C1**2*x + (C1 + 1)*x**2'),x)
    (C0 + C1*x + C2*x**2, {C2: C1 + 1, C0: 2*C1, C1: C1**2})

There is only 1 constant on the right; additive and multiplicative
absorbing occurred in defining C0 and C2 so we are free to re-write the
C0-C2 in term of C1 from either of those expressions:

    >>> e, r = _
    >>> ri=r.items()
    >>> e.subs([(o,n.subs(C1,solve(Eq(*ri[0]),C1)[0])) for o,n in ri])
    C2*x**2 + 2*C2 + x*(C2 - 1)**2 - 2
    >>> e.subs([(o,n.subs(C1,solve(Eq(*ri[1]),C1)[0])) for o,n in ri])
    C0**2*x/4 + C0 + x**2*(C0/2 + 1)

Again...neither of these is really simpler than you started with, are they?

/c

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

Reply via email to