Ask Your Question

# Problem with partial fraction's decomposition

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 close merge delete

## 1 Answer

Sort by » oldest newest most voted

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)

more

## Comments

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

( 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

## Stats

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

Seen: 167 times

Last updated: May 28 '21