Skip to content

Instantly share code, notes, and snippets.

@onionmk2
Created August 13, 2017 19:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save onionmk2/d424e83f4fda6eaf07f22312ad2dd5b4 to your computer and use it in GitHub Desktop.
Save onionmk2/d424e83f4fda6eaf07f22312ad2dd5b4 to your computer and use it in GitHub Desktop.
絶対値の方程式を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