```python= def newton(f, f_p, eps=10**(-4)): x = 0 # print(f(x), eps) while abs(f(x)) > eps: x = x-f(x)/f_p(x) # print(x) return x if __name__ == "__main__": from math import exp def f(x): return x ** 2+x-1 def f_prime(x): return 2*x+1 def g(x): return x**2-5*x+2-exp(x) def g_prime(x): return 2*x-5-exp(x) print(newton(f, f_prime)) print(newton(g, g_prime, 10**-2)) ``` 上のコードでnewton法で計算できる(微分は手計算しました)。この時newtonの一つ目と二つ目の引数は関数なのでこんな感じでadapt_simpsonにfをわたせばいいんじゃないでしょうか? PS.関数型は型ヒントをだすのがめんどうです
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up