midsummer night
6月21日は夏至 summer solstice です。
夏至といえば毎年メンデルスゾーンの真夏の夜の夢だったのですが、midsummer night は夏至の日の前の晩を指すようです。
AI と学ぶ真夏の夜の夢
import numpy as np import matplotlib.pyplot as plt # Given values for a^2 and b^2 a2 = 810 b2 = 1000 pi_value = np.pi # Compute the semi-major and semi-minor axes a = np.sqrt(a2) b = np.sqrt(b2) # Parameters for the ellipse theta = np.linspace(0, 2 * np.pi, 1000) x = a * np.cos(theta) y = b * np.sin(theta) # Rotate the ellipse by -45 degrees angle = np.radians(-45) cos_angle = np.cos(angle) sin_angle = np.sin(angle) x_rotated = x * cos_angle - y * sin_angle y_rotated = x * sin_angle + y * cos_angle # Scale the ellipse to satisfy the equation = pi scaling_factor = np.sqrt(pi_value) x_scaled = x_rotated * scaling_factor y_scaled = y_rotated * scaling_factor # Plot the ellipse plt.figure(figsize=(10, 6)) plt.fill(x_scaled, y_scaled, '#BC8F8F', label=r'$\frac{(x+y)^2}{810} + \frac{(x-y)^2}{1000} = \pi$') plt.title('A Midsummer Night’s Dream') plt.xlabel('x-axis') plt.ylabel('y-axis') plt.axhline(0, color='gray', lw=0.5) plt.axvline(0, color='gray', lw=0.5) plt.legend() plt.grid(True) plt.axis('equal') plt.show()
AI と学ぶ四色問題
John Backus も取り組んだ四色問題ですが、ここでは男色問題・・・
import matplotlib.pyplot as plt import matplotlib.patches as patches import numpy as np # 描画領域の設定 fig, ax = plt.subplots(figsize=(8, 6)) # 色の設定 color_circle = '#BC8F8F' # 円の色 color_top_left = '#A8C3C4' # 左上の色 color_top_right = '#D3C9B3' # 右上の色 color_bottom = '#3F3548' # 下の色 # 頂点の座標を定義 triangle1 = [[-0.1, 1], [0.5, 1.0], [0.5, 0.5], [-0.1, 0.2]] triangle2 = [[ 1.1, 1], [0.5, 1.0], [0.5, 0.5], [ 1.1, 0.2]] triangle3 = [[-0.1, 0], [1.1, 0], [1.2, 0.2], [0.5, 0.5], [-0.1,0.2]] # 三角形の描画 ax.add_patch(patches.Polygon(triangle1, color=color_top_left, zorder=0)) ax.add_patch(patches.Polygon(triangle2, color=color_top_right, zorder=0)) ax.add_patch(patches.Polygon(triangle3, color=color_bottom, zorder=0)) # 円の描画 circle = patches.Circle((0.5, 0.5), 0.3, color=color_circle, zorder=1) ax.add_patch(circle) # 軸の設定 ax.set_xlim(-0.1, 1.1) ax.set_ylim(0, 1) ax.set_aspect('equal') ax.axis('off') plt.show()
Apple Vision Pro
(Cyclops)
メンデルスゾーン
この CD 好き。変な箱に入っているけど。