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)
zoom_factor = 1.0 # Initial zoom factor
# Function to update the plot based on the value of 'a' and zoom scale
def update_plot(a, scale):
# Clear the current output to avoid overlap
clear_output(wait=True)
global zoom_factor
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.xlim([-scale / zoom_factor, scale / zoom_factor])
plt.ylim([-scale / zoom_factor, scale / zoom_factor])
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
)
# Define buttons for zoom in and zoom out
zoom_in_button = widgets.Button(description="Zoom In")
zoom_out_button = widgets.Button(description="Zoom Out")
# Define button click event handlers
def zoom_in(event):
global zoom_factor
zoom_factor *= 1.1
update_plot(a_slider.value, scale_slider.value)
def zoom_out(event):
global zoom_factor
zoom_factor /= 1.1
update_plot(a_slider.value, scale_slider.value)
# Attach event handlers to buttons
zoom_in_button.on_click(zoom_in)
zoom_out_button.on_click(zoom_out)
# Display the sliders and buttons
display(a_slider, scale_slider, zoom_in_button, zoom_out_button)
widgets.interact(update_plot, a=a_slider, scale=scale_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)
zoom_factor = 1.0
# Function to update the plot based on the value of 'a' and zoom scale
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} + 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 * zoom_factor, scale * zoom_factor])
plt.ylim([-scale * zoom_factor, scale * zoom_factor])
plt.show()
# Slider for 'a'
a_slider = widgets.FloatSlider(
value=0.3,
min=0,
max=1,
step=0.001,
description='a: ',
continuous_update=True
)
# Slider for scale
scale_slider = widgets.FloatSlider(
value=5,
min=1,
max=50,
step=1,
description='Scale: ',
continuous_update=True
)
# Buttons for zoom in and out
zoom_in_button = widgets.Button(description="Zoom In")
zoom_out_button = widgets.Button(description="Zoom Out")
# Click event handlers
def zoom_in(event):
global zoom_factor
zoom_factor /= 1.1
update_plot(a_slider.value, scale_slider.value)
def zoom_out(event):
global zoom_factor
zoom_factor *= 1.1
update_plot(a_slider.value, scale_slider.value)
# Attachments
zoom_in_button.on_click(zoom_in)
zoom_out_button.on_click(zoom_out)
# Plot Display
display(a_slider, scale_slider, zoom_in_button, zoom_out_button)
widgets.interact(update_plot, a=a_slider, scale=scale_slider)