GOLDEN ratio.yml #2
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
pi-golden-ratio/
├── main.py
├── requirements.txt
└── README.md
Main.py
import numpy as np
import matplotlib.pyplot as plt
import argparse
def golden_rectangle_plot(phi, pi_val, width=1):
height = width / phi
fig, ax = plt.subplots()
# Main rectangle
rect = plt.Rectangle((0, 0), width, height, fill=None, edgecolor='gold', linewidth=2)
ax.add_patch(rect)
# Square inside
square = plt.Rectangle((0, 0), height, height, fill=None, edgecolor='blue', linewidth=2)
ax.add_patch(square)
# Arc using pi
arc = plt.Arc((height, height), 2height, 2height, angle=0, theta1=0, theta2=180, edgecolor='red', linewidth=2)
ax.add_patch(arc)
ax.set_xlim(-0.2, width+0.2)
ax.set_ylim(-0.2, height+0.2)
ax.set_aspect('equal')
plt.title(f'Golden Rectangle (φ ≈ {phi:.5f}), Arc (π ≈ {pi_val:.5f})')
plt.show()
def fibonacci_spiral_plot(n_terms=10):
phi = (1 + np.sqrt(5)) / 2
a, b = 1, 1
x, y = 0, 0
angle = 0
pts = [(x, y)]
for _ in range(n_terms):
x += np.cos(np.deg2rad(angle)) * b
y += np.sin(np.deg2rad(angle)) * b
pts.append((x, y))
a, b = b, a + b
angle += 90
pts = np.array(pts)
plt.plot(pts[:,0], pts[:,1], marker='o')
plt.title("Fibonacci Spiral (approaches golden ratio)")
plt.axis('equal')
plt.show()
def main():
parser = argparse.ArgumentParser(description='π and Golden Ratio Visualizations')
parser.add_argument('--rectangle', action='store_true', help='Plot golden rectangle with arc using π')
parser.add_argument('--spiral', action='store_true', help='Plot Fibonacci spiral')
parser.add_argument('--phi', type=float, default=(1 + np.sqrt(5)) / 2, help='Golden ratio value (default φ)')
parser.add_argument('--pi', type=float, default=np.pi, help='Pi value (default π)')
parser.add_argument('--terms', type=int, default=10, help='Terms in Fibonacci spiral')
args = parser.parse_args()
if name == "main":
main()
numpy
matplotlib
π and Golden Ratio (φ) Exploration
This repository demonstrates mathematical and geometric relationships between π (pi ≈ 3.14159) and the golden ratio (φ ≈ 1.61803) using Python visualizations.
Features
Usage
License
MIT License
Here are resources with transcendence proofs:
A concise exposition for π:
Simple proofs: Pi is transcendental « Math Scholar
Mathematical StackExchange discussion and references: Proof π is transcendental without symmetric function theory
The Stacks Project on transcendence bases, including π:
Section 9.26: Transcendence—The Stacks project
The golden ratio φ is not transcendental (it is algebraic: the root of x² − x − 1 = 0), so proofs of transcendence are only relevant for π and similar numbers.