Updates:
        Owner: asmeurer
        Labels: Integration

Comment #9 on issue 829 by asmeurer: Improve simplify() to handle result from integrate(log(k**2-m**2), k)
http://code.google.com/p/sympy/issues/detail?id=829

This is what it is going to look like with the new Risch integrator:


In [17]: a = integrate_primitive(Poly(t, t), Poly(1, t), [Poly(1, k), Poly(2*k/(k**2 - m**2), t)], [k, t], [lambda k: log(k**2 - m**2)])

In [18]: a
Out[18]:
⎛                 ⌠                 ⎞
⎜                 ⎮      2          ⎟
⎜     ⎛ 2    2⎞   ⎮  -2⋅k           ⎟
⎜k⋅log⎝k  - m ⎠ + ⎮ ─────── dk, True⎟
⎜                 ⎮  2    2         ⎟
⎜                 ⎮ k  - m          ⎟
⎝                 ⌡                 ⎠

In [19]: a[0].doit()
Out[19]:
            ⎛ 2    2⎞
-2⋅k + k⋅log⎝k  - m ⎠ + │m│⋅log(k + │m│) - │m│⋅log(k - │m│)

Note that this is with the default setting where m and k are integers. If they are regular symbols, the result is a little more complicated for both (though still simpler for the new algorithm):

In [20]: var('k m')
Out[20]: (k, m)

In [21]: a = integrate_primitive(Poly(t, t), Poly(1, t), [Poly(1, k), Poly(2*k/(k**2 - m**2), t)], [k, t], [lambda k: log(k**2 - m**2)])

In [22]: a
Out[22]:
⎛                 ⌠                 ⎞
⎜                 ⎮      2          ⎟
⎜     ⎛ 2    2⎞   ⎮  -2⋅k           ⎟
⎜k⋅log⎝k  - m ⎠ + ⎮ ─────── dk, True⎟
⎜                 ⎮  2    2         ⎟
⎜                 ⎮ k  - m          ⎟
⎝                 ⌡                 ⎠

In [23]: a[0].doit()
Out[23]:
                           ⎽⎽⎽⎽    ⎛       ⎽⎽⎽⎽⎞      ⎽⎽⎽⎽    ⎛       ⎽⎽⎽⎽⎞
            ⎛ 2    2⎞     ╱  2     ⎜      ╱  2 ⎟     ╱  2     ⎜      ╱  2 ⎟
-2⋅k + k⋅log⎝k  - m ⎠ + ╲╱  m  ⋅log⎝k + ╲╱  m  ⎠ - ╲╱  m  ⋅log⎝k - ╲╱  m  ⎠

In [24]: integrate(log(k**2-m**2), k)
Out[24]:
                                                  ⎛       ⎽⎽⎽⎽⎞
                         2    ⎛ 2    2⎞      2    ⎜      ╱  2 ⎟
            ⎛ 2    2⎞   m ⋅log⎝k  - m ⎠   2⋅m ⋅log⎝k + ╲╱  m  ⎠
-2⋅k + k⋅log⎝k  - m ⎠ - ─────────────── + ─────────────────────
                               ⎽⎽⎽⎽                 ⎽⎽⎽⎽
                              ╱  2                 ╱  2
                            ╲╱  m                ╲╱  m

And for what it's worth, the new algorithm is  superbly faster:

In [25]: %timeit integrate_primitive(Poly(t, t), Poly(1, t), [Poly(1, k), Poly(2*k/(k**2 - m**2), t)], [k, t], [lambda k: log(k**2 - m**2)])[0].doit()
10 loops, best of 3: 150 ms per loop

In [26]: %timeit integrate(log(k**2-m**2), k)
1 loops, best of 3: 2.98 s per loop


--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" 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-issues?hl=en.

Reply via email to