1. mrrclb48z

    Posted

    mrrclb48z
Changes in title
+sympyで「フィボナッチ数(Fibonacci number)」の一般項を出力した。
Changes in tags
Changes in body
Source | HTML | Preview

(参考)Python3モジュールブック>階差方程式の求解
http://www.k-techlabo.org/www_python/python_modules.pdf#page=72
(参考)sympy>class sympy.functions.combinatorial.numbers.fibonacci
http://docs.sympy.org/latest/_modules/sympy/functions/combinatorial/numbers.html#fibonacci
(参考)Fibonacci number
https://en.wikipedia.org/wiki/Fibonacci_number

from sympy import *
f = simplify('f(n)')
s = simplify('f(n+2)-f(n+1)-f(n)')
ini = simplify('{f(0):0,f(1):1}')
print(rsolve(s,f,ini))

wolframalpha

(参考)Fibonacci?Wolfram Language Documentation
http://reference.wolfram.com/language/ref/Fibonacci.html
(参考)オンライン mathematica
http://www.wolframalpha.com/input/?i=RSolve%5B%7Ba%5Bn%2B2%5D+%3D%3D+a%5Bn%5D%2Ba%5Bn%2B1%5D,+a%5B0%5D+%3D%3D+0,a%5B1%5D+%3D%3D+1%7D,+a%5Bn%5D,+n%5D
何か違います。