Eliguli / NYU-CAS-Meows-Corp-Association

1 stars 0 forks source link

Machine Learning-Riemann Zeta Function #2

Open Eliguli opened 2 weeks ago

Eliguli commented 2 weeks ago

Riemann Zeta Functions with Scaling and arbitrary R(ζ(s))

import numpy as np
import matplotlib.pyplot as plt
import mpmath as mp
import ipywidgets as widgets
from IPython.display import display

# Define the range for the imaginary part b
b_val = np.linspace(0, 100, 10000)

# Function to update the plot based on the value of 'a'
def update_plot(a):
    # Clear the current plot to avoid overlap
    plt.clf()

    zeta_val = [mp.zeta(complex(a, b)) for b in b_val]
    zeta_real = [mp.re(zeta) for zeta in zeta_val]
    zeta_imag = [mp.im(zeta) for zeta in zeta_val]

    plt.figure(figsize=(10, 10))
    plt.plot(zeta_real, zeta_imag, label=f'ζ({a} + bi)')
    plt.title(f'Plot of ζ({a} + bi) in the Complex Plane')
    plt.xlabel('Re(ζ(a + bi))')
    plt.ylabel('Im(ζ(a + bi))')
    plt.grid(True)
    plt.axhline(y=0, color='k', linestyle='--')
    plt.axvline(x=0, color='k', linestyle='--')
    plt.legend()
    plt.show()

# Define the slider for 'a'
a_slider = widgets.FloatSlider(
    value=0.3,
    min=0,
    max=1,
    step=0.001,
    description='a: ',
    continuous_update=True
)

widgets.interact(update_plot, a=a_slider)
#%%
import numpy as np
import matplotlib.pyplot as plt
import mpmath as mp
import ipywidgets as widgets
from IPython.display import display

# Define the range for the imaginary part b
b_val = np.linspace(0, 100, 10000)

# Function to update the plot based on the value of 'a'
def update_plot(a):
    # Clear the current plot to avoid overlap
    plt.clf()

    zeta_val = [mp.zeta(complex(a, b)) for b in b_val]
    zeta_real = [mp.re(zeta) for zeta in zeta_val]
    zeta_imag = [mp.im(zeta) for zeta in zeta_val]

    plt.figure(figsize=(10, 10))
    plt.plot(zeta_real, zeta_imag, label=f'ζ({a} + bi)')
    plt.title(f'Plot of ζ({a} + bi) in the Complex Plane')
    plt.xlabel('Re(ζ(a + bi))')
    plt.ylabel('Im(ζ(a + bi))')
    plt.grid(True)
    plt.axhline(y=0, color='k', linestyle='--')
    plt.axvline(x=0, color='k', linestyle='--')
    plt.gca().set_aspect('equal', adjustable='box')
    plt.legend()
    plt.show()

# Define the slider for 'a'
a_slider = widgets.FloatSlider(
    value=0.3,
    min=0,
    max=1,
    step=0.001,
    description='a: ',
    continuous_update=True
)

widgets.interact(update_plot, a=a_slider)

image image

import numpy as np
import matplotlib.pyplot as plt
import mpmath as mp
import ipywidgets as widgets
from IPython.display import display

# Define a grid in the complex plane
x = np.linspace(-10, 10, 400)
y = np.linspace(-10, 10, 400)
X, Y = np.meshgrid(x, y)
Z = X + 1j * Y

# Function to update the plot based on the value of 'a'
def update_plot(a):
    # Clear the current plot to avoid overlap
    plt.clf()

    # Apply the Riemann zeta function to the grid
    Z_transformed = np.array([[mp.zeta(complex(a, b)) for b in row] for row in Z])

    # Extract real and imaginary parts
    Z_real = np.real(Z_transformed)
    Z_imag = np.imag(Z_transformed)

    # Create the plot
    plt.figure(figsize=(10, 10))
    plt.plot(Z_real, Z_imag, 'b.', markersize=0.5, alpha=0.5)  # Use dots to represent the transformed points

    plt.title(f'Transformation of Complex Plane by ζ({a} + bi)')
    plt.xlabel('Re(ζ(a + bi))')
    plt.ylabel('Im(ζ(a + bi))')
    plt.grid(True)
    plt.axhline(y=0, color='k', linestyle='--')
    plt.axvline(x=0, color='k', linestyle='--')
    plt.gca().set_aspect('equal', adjustable='box')
    plt.show()

# Define the slider for 'a'
a_slider = widgets.FloatSlider(
    value=0.5,
    min=0,
    max=1,
    step=0.01,
    description='a: ',
    continuous_update=True
)

widgets.interact(update_plot, a=a_slider)
import numpy as np
import matplotlib.pyplot as plt
import mpmath as mp
import ipywidgets as widgets
from IPython.display import display

# Define a grid in the complex plane
x = np.linspace(-10, 10, 400)
y = np.linspace(-10, 10, 400)
X, Y = np.meshgrid(x, y)
Z = X + 1j * Y

# Function to update the plot based on the value of 'a'
def update_plot(a):
    # Clear the current plot to avoid overlap
    plt.clf()

    # Apply the Riemann zeta function to the grid
    Z_transformed = np.array([[mp.zeta(complex(a, b)) for b in row] for row in Z])

    # Extract real and imaginary parts
    Z_real = np.real(Z_transformed)
    Z_imag = np.imag(Z_transformed)

    # Create the plot
    plt.figure(figsize=(15, 15))

    # Plot the original grid
    for i in range(Z.shape[0]):
        plt.plot(np.real(Z[i, :]), np.imag(Z[i, :]), color='blue', alpha=0.3)
    for j in range(Z.shape[1]):
        plt.plot(np.real(Z[:, j]), np.imag(Z[:, j]), color='blue', alpha=0.3)

    # Plot the transformed grid
    for i in range(Z.shape[0]):
        plt.plot(Z_real[i, :], Z_imag[i, :], color='red', alpha=0.6)
    for j in range(Z.shape[1]):
        plt.plot(Z_real[:, j], Z_imag[:, j], color='red', alpha=0.6)

    plt.title(f'Transformation of Complex Plane by ζ({a} + bi)')
    plt.xlabel('Re')
    plt.ylabel('Im')
    plt.grid(True)
    plt.axhline(y=0, color='k', linestyle='--')
    plt.axvline(x=0, color='k', linestyle='--')
    plt.gca().set_aspect('equal', adjustable='box')
    plt.legend(['Original Grid', 'Transformed Grid'])
    plt.show()

# Define the slider for 'a'
a_slider = widgets.FloatSlider(
    value=0.5,
    min=0,
    max=1,
    step=0.01,
    description='a: ',
    continuous_update=True
)

widgets.interact(update_plot, a=a_slider)
#%%
import numpy as np
import matplotlib.pyplot as plt
import mpmath as mp
import ipywidgets as widgets
from IPython.display import display

# Define the range for the imaginary part b
b_val = np.linspace(0, 100, 10000)

# Function to update the plot based on the value of 'a'
def update_plot(a):
    # Clear the current plot to avoid overlap
    plt.clf()

    zeta_val = [mp.zeta(complex(a, b)) for b in b_val]
    zeta_real = [mp.re(zeta) for zeta in zeta_val]
    zeta_imag = [mp.im(zeta) for zeta in zeta_val]

    plt.figure(figsize=(10, 10))
    plt.plot(zeta_real, zeta_imag, label=f'ζ({a} + bi)')
    plt.title(f'Plot of ζ({a} + bi) in the Complex Plane')
    plt.xlabel('Re(ζ(a + bi))')
    plt.ylabel('Im(ζ(a + bi))')
    plt.grid(True)
    plt.axhline(y=0, color='k', linestyle='--')
    plt.axvline(x=0, color='k', linestyle='--')
    plt.gca().set_aspect('equal', adjustable='box')
    plt.legend()
    plt.show()

# Define the slider for 'a'
a_slider = widgets.FloatSlider(
    value=0.3,
    min=0,
    max=1,
    step=0.001,
    description='a: ',
    continuous_update=True
)

widgets.interact(update_plot, a=a_slider)
import numpy as np
import matplotlib.pyplot as plt
import mpmath as mp
import ipywidgets as widgets
from IPython.display import display, clear_output

# Define the range for the imaginary part b
b_val = np.linspace(0, 100, 10000)

# Function to update the plot based on the value of 'a'
def update_plot(a, scale):
    # Clear the current output to avoid overlap
    clear_output(wait=True)

    zeta_val = [mp.zeta(complex(a, b)) for b in b_val]
    zeta_real = [mp.re(zeta) for zeta in zeta_val]
    zeta_imag = [mp.im(zeta) for zeta in zeta_val]

    plt.figure(figsize=(10, 10))
    plt.plot(zeta_real, zeta_imag, label=f'ζ({a:.3f} + bi)')
    plt.title(f'Plot of ζ({a} + bi) in the Complex Plane')
    plt.xlabel('Re(ζ(a + bi))')
    plt.ylabel('Im(ζ(a + bi))')
    plt.grid(True)
    plt.axhline(y=0, color='k', linestyle='--')
    plt.axvline(x=0, color='k', linestyle='--')
    plt.legend()
    plt.xlim([-scale, scale])
    plt.ylim([-scale, scale])
    plt.show()

# Define the slider for 'a'
a_slider = widgets.FloatSlider(
    value=0.3,
    min=0,
    max=1,
    step=0.001,
    description='a: ',
    continuous_update=True
)

# Define the slider for scale
scale_slider = widgets.FloatSlider(
    value=5,
    min=1,
    max=50,
    step=1,
    description='Scale: ',
    continuous_update=True
)

# Create interactive widgets
widgets.interact(update_plot, a=a_slider, scale=scale_slider)
#%%
import numpy as np
import matplotlib.pyplot as plt
import mpmath as mp
from matplotlib.animation import FuncAnimation

# Define the range for the imaginary part b
b_val = np.linspace(0, 100, 10000)

# Function to calculate zeta values
def calculate_zeta(a):
    zeta_val = [mp.zeta(complex(a, b)) for b in b_val]
    zeta_real = [mp.re(zeta) for zeta in zeta_val]
    zeta_imag = [mp.im(zeta) for zeta in zeta_val]
    return zeta_real, zeta_imag

# Initialize the plot
fig, ax = plt.subplots(figsize=(10, 10))
line, = ax.plot([], [], lw=2)
ax.grid(True)
ax.axhline(y=0, color='k', linestyle='--')
ax.axvline(x=0, color='k', linestyle='--')
ax.set_xlim(-5, 5)
ax.set_ylim(-5, 5)

# Update function for animation
def update(a):
    zeta_real, zeta_imag = calculate_zeta(a)
    line.set_data(zeta_real, zeta_imag)
    ax.set_title(f'Plot of ζ({a:.2f} + bi) in the Complex Plane')
    return line,

# Create animation
a_values = np.linspace(0.1, 1, 100)
ani = FuncAnimation(fig, update, frames=a_values, blit=True, repeat=False)

plt.show()
from IPython.display import HTML

# Display the animation inline in a Jupyter Notebook
HTML(ani.to_jshtml())