import%20marimo%20as%20mo%0Aimport%20matplotlib.pyplot%20as%20plt%0Aimport%20numpy%20as%20np
frequency%20%3D%20mo.ui.slider(1%2C%205%2C%20value%3D1%2C%20step%3D1%2C%20label%3D'Frequency')%0Aamplitude%20%3D%20mo.ui.slider(1%2C%203%2C%20value%3D1%2C%20step%3D0.25%2C%20label%3D'Amplitude')
This uses Marimo to create a reactive page illustrating the parameters of the sine-function. The sliders change the amplitude and frequency which reactively recomputes the plot using Pyodide.
The formula below with the formula also changes based on the sliders.
mo.md(%0A%20%20%20%20f%22%22%22%0A%20%20%20%20%24%24%0A%20%20%20%20f(x)%20%3D%20%7Bamplitude.value%7D%20%5Ccdot%20%5Csin(%7Bfrequency.value%7D%5Cpi%20%20x)%0A%20%20%20%20%24%24%0A%0A%20%20%20%20%7Bfrequency%7D%0A%20%20%20%20%7Bamplitude%7D%0A%20%20%20%20%22%22%22%0A)
fig%2C%20ax%20%3D%20plt.subplots(figsize%3D(8%2C%204))%0A%0Adef%20sine(x%2C%20freq%2C%20amp)%3A%0A%20%20%20%20return%20amp*np.sin(x*freq*np.pi)%0A%0Ax%20%3D%20np.linspace(0%2C%205%2C%20300)%0A%0Aax.plot(x%2C%20sine(x%2C%20frequency.value%2C%20amplitude.value))%0Aax.set_xlim(x.min()%2C%20x.max())%0Aax.set_ylim(-amplitude.stop-0.1%2C%20amplitude.stop%2B0.1)%0A%0Amo.center(fig)