rtoy / maxima

A Clone of Maxima's repo
Other
0 stars 0 forks source link

partfrac() problem with complex fraction #2309

Open rtoy opened 2 months ago

rtoy commented 2 months ago

Imported from SourceForge on 2024-07-05 23:37:54 Created by twolterink on 2023-04-21 10:22:13 Original: https://sourceforge.net/p/maxima/bugs/4132


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

Attachments:

rtoy commented 2 months ago

Imported from SourceForge on 2024-07-05 23:37:55 Created by willisbl on 2023-04-21 10:54:45 Original: https://sourceforge.net/p/maxima/bugs/4132/#f9fc


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.

rtoy commented 2 months ago

Imported from SourceForge on 2024-07-05 23:37:59 Created by macrakis on 2023-04-21 17:32:50 Original: https://sourceforge.net/p/maxima/bugs/4132/#24c0


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)))....

rtoy commented 2 months ago

Imported from SourceForge on 2024-07-05 23:38:02 Created by macrakis on 2023-04-21 17:33:09 Original: https://sourceforge.net/p/maxima/bugs/4132/#f240