Instantly share code, notes, and snippets.

Embed
What would you like to do?
絶対値の方程式をsympyで
# 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