Professional Documents
Culture Documents
In [23]: # Problem 2
# Part A
x,A,B,C,D = symbols('x,A,B,C,D')
f = (x**3 + 2) / (x**4 + 4*x**2 + 3)
eq1 = A + C - 1
eq2 = B + D
eq3 = A + 3*C
eq4 = B + 3*D - 2
coeffs = solve([eq1,eq2,eq3,eq4],[A,B,C,D])
print('The coefficients of the split fraction are:', coeffs)
The coefficients of the split fraction are: {A: 3/2, B: -1, C: -1/2, D: 1}
In [24]: # Part B
print('The coefficients found using the apart function are equal to those cal
fnew = apart(f,x)
fnew
The coefficients found using the apart function are equal to those calculat
ed using the manual method in part a
Out[24]:
− 2 𝑥𝑥2−+21 + 2 3𝑥𝑥2−+23
( ) ( )
In [25]: # Part C
integral = integrate(fnew,x)
integral
Out[25]:
log (𝑥2 + 1) 3log (𝑥2 + 3) √⎯⎯3 atan ( √33𝑥 )
− 4 + 4 + atan(𝑥) − 3
In [26]: # Part C Check
print('The two methods give equivalent integrals')
integral2 = integrate(f,x)
integral2
Out[26]:
log (𝑥2 + 1) 3log (𝑥2 + 3) √⎯⎯3 atan ( √33𝑥 )
− 4 + 4 + atan(𝑥) − 3
localhost:8888/notebooks/.ipynb# 1/2
3/1/2020 .ipynb - Jupyter Notebook
localhost:8888/notebooks/.ipynb# 2/2