Ask Your Question
1

Problem with partial fraction's decomposition

asked 2021-05-28 07:03:35 +0100

Spyridon Kanavos gravatar image

updated 2021-05-28 12:54:31 +0100

FrédéricC gravatar image

I’m trying to do a partial fraction decomposition using respectively x, and k as variable and parameter. Running on sagemath there’s a problem. The code is

x, k=var('x','k');
f1=1;
f2=k^2 - x^2;
f12=f1/f2;
f=f12(x).partial_fraction();
fi = integral(f12,x);
print (latex(f));
print (latex(fi));

and the message:

ValueError: power::eval(): division by zero.

Probably I have to assume that f2 not equal to 0, but how. Any help?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2021-05-28 09:50:50 +0100

Sébastien gravatar image

updated 2021-05-28 09:51:39 +0100

You should do f12.partial_fraction() as opposed to f12(x).partial_fraction()

sage: x, k=var('x','k'); f1=1; f2=k^2 - x^2; f12=f1/f2                          
sage: f12                                                                       
1/(k^2 - x^2)
sage: f12.partial_fraction()                                                    
-1/2/((k + x)*x) + 1/2/((k - x)*x)

This raises the error you mention:

sage: f12(x)                                                                    
Traceback (most recent call last):
...
ValueError: power::eval(): division by zero

Note that this works too (maybe this is what you intended?):

sage: f12(x,k)                                                                  
-1/(k^2 - x^2)
sage: f12(x,k).partial_fraction()                                               
1/2/((k + x)*x) - 1/2/((k - x)*x)
edit flag offensive delete link more

Comments

It works perfectly into two cases as well. Thanks, Sebastian, thanks a lot.

Spyridon Kanavos gravatar imageSpyridon Kanavos ( 2021-05-28 11:18:02 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2021-05-28 07:03:35 +0100

Seen: 468 times

Last updated: May 28 '21