Created
May 5, 2018 14:16
-
-
Save devlights/f2e49549afbec3c15b1b113412540204 to your computer and use it in GitHub Desktop.
[python][sympy] python の sympy つかって因数分解
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sympy | |
# x を定義 | |
x = sympy.Symbol('x') | |
# 式定義 | |
# x^3 - 2x^2 - 5x + 6 | |
expr = x**3 - 2*(x**2) - 5*x + 6 | |
print(expr) | |
# 因数分解 | |
result = sympy.factor(expr) | |
print(result) | |
# 展開 | |
print(sympy.expand(result)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment