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
For a workaround, call
gfactor
beforepartfrac.
For exampleThe 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 thepartfrac
code.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 yield1/(2^(3/2)*(x-sqrt(2)))-1/(2^(3/2)*(x+sqrt(2)))
....Last edit: Stavros Macrakis 2023-04-21