Skip to content
DeepForgeby svx
All problems
MediumCalculusca-118

Inverse Laplace Partial-Fraction Coefficients

Problem

Decompose F(s) = (s + c) / ((s - a) * (s - b)) into partial fractions A / (s - a) + B / (s - b).

Cover-up gives A = (a + c) / (a - b) and B = (b + c) / (b - a). Return [A, B]. Assume a != b.

Hint

Evaluate the numerator at each pole after cancelling the corresponding factor.

Test cases

case 1
in: [1,-2,3]
expected: [1.3333333333333333,-0.3333333333333333]
case 2
in: [0,-1,0]
expected: [0,1]
case 3
in: [2,3,5]
expected: [-7,8]
case 4
in: [-1,1,-1]
expected: [1,0]
Starter codePython
def partial_fraction_coeffs(a, b, c):
    # Return [A, B]
    # Your code here
    pass

4 test cases · run your code against them in the editor