Created
August 13, 2017 19:59
-
-
Save onionmk2/d424e83f4fda6eaf07f22312ad2dd5b4 to your computer and use it in GitHub Desktop.
絶対値の方程式をsympyで
This file contains 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
# http://www7b.biglobe.ne.jp/~h-kuroda/pdf/text_calculus.pdf 1.1(1)を解く | |
import numpy as np | |
from sympy import * | |
# real = trueがないと死ぬ。 | |
# https://stackoverflow.com/questions/33188668/how-to-solve-absolute-value-equations-using-sympy | |
x = symbols("x", real=True) | |
f = np.absolute(x + 2) - 4 | |
roots = solve(f, x) | |
print(roots) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment