Home > Python > Basic Python Programs

Ch. 3.8 Miscellaneous Problems

Chapters Index
Program 1

Miscellaneous Problems

Python 3.11 Ready

                                
Click "Run Code" to execute script and render figures.

Mathematical Problem Formulation

Fibonacci Numbers

Fibonacci Sequence

The Fibonacci numbers may be defined by the recurrence relation:

\[ F_0 = 0, \quad F_1 = 1, \]

and

\[ F_n = F_{n-1} + F_{n-2} \quad \text{for } n > 1. \]

Theoretical Principles & Computational Physics Guide

Miscellaneous Computational Problems: Numerical Sequences & Special Algorithms

Dr. Alorika Chatterjee & Dr. Anirban Shaw Science & Physics Learners Python 3 / NumPy / SciPy

1. Core Principles & Theoretical Framework

Fundamental Recurrences: Explores famous numerical series including Fibonacci sequences, Pascal's triangle, and digital invariants.
Dynamic Programming: Demonstrates state memoization to transform exponential recursive algorithms into linear time.
Physical Analogies: Fibonacci ratios converge to the Golden Ratio $\phi = (1 + \sqrt{5})/2$, modeling phyllotaxis and quasi-crystal structures.

2. Mathematical Formulation & Algorithmic Pipeline

Fibonacci recurrence and convergence to the Golden Ratio:

$$ F_n = F_{n-1} + F_{n-2}, \quad \lim_{n\to\infty} \frac{F_n}{F_{n-1}} = \phi = \frac{1 + \sqrt{5}}{2} \approx 1.6180339887 $$

3. Numerical Mechanics & Implementation Logic

  • Iterative State Shift: Maintain two variables $(a, b)$; update in parallel via a, b = b, a + b.
  • Memoization: Cache computed sequence values to avoid redundant tree evaluation.
  • Bitwise Checks: Use modular arithmetic and digital decomposition to check numerical symmetry properties.

4. Relevant Computational Practice Exercises

Exercise 1
Generate the first 50 Fibonacci numbers iteratively and plot the ratio $F_n / F_{n-1}$ demonstrating convergence to $\phi$.
Exercise 2
Write a function to check if a 3-digit number is an Armstrong number (sum of cubes of digits equals the number).
Exercise 3
Generate Pascal's Triangle up to $N = 10$ rows and show how each row corresponds to binomial coefficients $\binom{n}{k}$.
Standard Literature & References:
  • Donald E. Knuth, "The Art of Computer Programming", Addison-Wesley (1997).