Updates:
        Labels: -NeedsReview NeedsBetterPatch mattpap

Comment #10 on issue 2132 by asmeurer: Derivative of RootSum
http://code.google.com/p/sympy/issues/detail?id=2132

There is a bug:

In [11]: a = S("(1-5*x^2)/(x-2*x^3+x^5-1)")

In [12]: a
Out[12]:
    ⎛       2⎞
   -⎝1 - 5⋅x ⎠
─────────────────
           3    5
1 - x + 2⋅x  - x

In [13]: b = integrate(a, x)

In [14]: b
Out[14]:
        ⎛ 5           ⎛        ⎛     2⎞⎞⎞
-RootSum⎝t  - t - 1, Λ⎝t, t⋅log⎝x - t ⎠⎠⎠

In [15]: b.diff(x)
Out[15]:
5 - 12⋅s₆
─────────
 4 - 6⋅s₆

Also, do you think something like this should still work?

In [1]: RootSum(x**5 - x + 1, sin)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)

/Users/aaronmeurer/Documents/Python/sympy/sympy/<ipython console> in <module>()

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/polys/rootoftools.py in __new__(cls, expr, func, x)
    545             func = Lambda(poly.gen, poly.gen)
    546         elif not isinstance(func, Lambda) or func.nargs != 1:
--> 547 raise ValueError("expected a univariate Lambda, got %s" % func)
    548
    549         (_, factors), terms = poly.factor_list(), []

ValueError: expected a univariate Lambda, got sin

And it isn't so slow for me:

In [38]: a = RootSum(x**5 - x + 1, Lambda(z, z*log(x - z)))

In [39]: %timeit a.diff(x)
10 loops, best of 3: 84.2 ms per loop

In [40]: %timeit a = RootSum(x**5 - x + 1, Lambda(z, z*log(x - z)))
100 loops, best of 3: 2.11 ms per loop

By the way, this fix should also help me fix some problems I have been having in risch_integrate, namely with integrals that should return RootSum (like risch_integrate(1/(exp(5*x) + exp(x) + 1), x)). Basically, the integrator needs to be able to subtract the derivative of the RootSum in order to get the remaining part of the integral, but until this fix, it isn't possible.

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