Menu

#4132 partfrac() problem with complex fraction

None
not-a-bug
nobody
partfrac (2)
5
2023-04-21
2023-04-21
No

Hello,
today I found a (small) problem with the use of partfrac() for complex numbers.

I have tried some examples similar to that in the documentation.


/ First example works /
1/(z+%i) + (1)/(z+1);
ratsimp(%)$
partfrac(%,z);

/ Second example doesn't work /
1/(z+%i) + (1)/(z+1+%i);
ratsimp(%)$
partfrac(%,z);

/ Third example works again /
1/(z+1) + (1)/(z+1+%i);
ratsimp(%)$
partfrac(%,z);


Some more information can be found within the attached file.

Best regards,
Thorsten

1 Attachments

Discussion

  • Barton Willis

    Barton Willis - 2023-04-21

    For a workaround, call gfactor before partfrac. For example

    (%i5)   1/(z+%i) + (1)/(z+1+%i);
    (%o5)   1/(z+%i+1)+1/(z+%i)
    
    (%i6)   ratsimp(%);
    (%o6)   (2*z+2*%i+1)/(z^2+(2*%i+1)*z+%i-1)
    
    (%i7)   partfrac(gfactor(%),z);
    (%o7)   1/(z+%i+1)+1/(z+%i)
    

    The user documentation says that partfrac "does a complete partial fraction decomposition." In this context, I'm not sure that "complete" has a clear meaning, so I don't consider this to be a bug.

    We could insert a call to gfactor into the partfrac code.

     
  • Stavros Macrakis

    This is not a bug, but the intended behavior.

    The typical use case for partfrac is to calculate the real integrals of real integrands.
    Thus for example partfrac(1/(x^4-1),x) yields
    (-1/(2*(x^2+1)))-1/(4*(x+1))+1/(4*(x-1)),
    which can be integrated as (-log(x+1)/4)-atan(x)/2+log(x-1)/4.
    Most users do not want the result
    (-(%i*log(x+%i))/4)+(%i*log(x-%i))/4-log(x+1)/4+log(x-1)/4,
    even though it is of course equivalent -- though messy to simplify to the first form.

    As was mentioned above, you can use partfrac(gfactor(1/(x^4-1)),x).

    Similarly, most users will not want partfrac(1/(x^2-2),x) to yield 1/(2^(3/2)*(x-sqrt(2)))-1/(2^(3/2)*(x+sqrt(2)))....

     

    Last edit: Stavros Macrakis 2023-04-21
  • Stavros Macrakis

    • status: open --> not-a-bug
     

Log in to post a comment.