LoginSignup
0
0

More than 1 year has passed since last update.

部分分数分解 「15年 関西学院大 理系 2月1日 1(3)」をwolframalphaとsympyでやってみた。

Last updated at Posted at 2022-07-18

(2x^3-7x^2+11x-16)/(x(x-2)^3)
オリジナル

wolframalphaで

(2 x^3 - 7 x^2 + 11 x - 16)/(x (x - 2)^3)

以下、実行結果の順番は気になりますけど,ありました。

できませんでした。 wolframalphaのsolveを使って

solve((2x**3-7x**2+11x-16)/(x(x-2)**3)=a/x+b/(x-2)+c/(x-2)**2+d/(x-2)**3,[a,b,c,d])

solve((2x^3-7x^2+11x-16)/(x(x-2)^3)=a/x+b/(x-2)+c/(x-2)^2+d/(x-2)^3,[a,b,c,d])

sympyで(1)apartを使って

これも実行結果の順番は気になりますけど、ありました。

from sympy import *
var('x')
f=(2*x**3-7*x**2+11*x-16)/(x*(x-2)**3)
print (      f )
print (apart(f))
pprint(apart(f))
# (2*x**3 - 7*x**2 + 11*x - 16)/(x*(x - 2)**3)
# 5/(x - 2)**2 - 3/(x - 2)**3 + 2/x
#    5          3       2
# ──────── - ──────── + ─
#        2          3   x
# (x - 2)    (x - 2)  

sympyで(2)solveを使って

WolfMoon様のコメントより

from sympy import *
var('x a b c d')
print("#",solve(Eq((2*x**3-7*x**2+11*x-16)/(x*(x-2)**3), \
                     a/x+b/(x-2)+c/(x-2)**2+d/(x-2)**3), \
                [a,b,c,d]))
# {a: 2, b: 0, c: 5, d: -3}

sympyで(3)数値代入法のsolveを使って

4元連立方程式でした。
xに1,3,4,5を代入しました。xに2を代入すると,Falseがでました。

from sympy import *
var('x a b c d')
myEq=Eq((2*x**3-7*x**2+11*x-16)/(x*(x-2)**3),a/x+b/(x-2)+c/(x-2)**2+d/(x-2)**3)
print("#",solve([myEq.subs({x:1}),myEq.subs({x:3}),myEq.subs({x:4}),myEq.subs({x:5})],[a,b,c,d]))
# {a: 2, b: 0, c: 5, d: -3}

sympyで(4)係数比較法を使って

(勉強中)

0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0