Book Image

NumPy: Beginner's Guide

By : Ivan Idris
Book Image

NumPy: Beginner's Guide

By: Ivan Idris

Overview of this book

Table of Contents (21 chapters)
NumPy Beginner's Guide Third Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
NumPy Functions' References
Index

Fibonacci numbers


The Fibonacci numbers (see http://en.wikipedia.org/wiki/Fibonacci_number) are based on a recurrence relation:

It is difficult to express this relation directly with NumPy code. However, we can express this relation in a matrix form or use the following golden ratio formula:

with

This will introduce the matrix() and rint() functions. The matrix() function creates matrices and the rint() function rounds numbers to the closest integer, but the result is not an integer.