import%20marimo%0A%0A__generated_with%20%3D%20%220.14.17%22%0Aapp%20%3D%20marimo.App(width%3D%22medium%22)%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20import%20marimo%20as%20mo%0A%20%20%20%20import%20numpy%20as%20np%0A%20%20%20%20import%20numpy.typing%20as%20npt%0A%20%20%20%20import%20plotly.graph_objects%20as%20go%0A%20%20%20%20return%20go%2C%20mo%2C%20np%2C%20npt%0A%0A%0A%40app.cell%0Adef%20_(np%2C%20npt)%3A%0A%20%20%20%20def%20random_on_unit_circle(%0A%20%20%20%20%20%20%20%20rng%3A%20np.random.Generator%2C%20num_samples%3A%20int%0A%20%20%20%20)%20-%3E%20npt.NDArray%5Bcomplex%5D%3A%0A%20%20%20%20%20%20%20%20arg%20%3D%20rng.uniform(0%2C%202%20*%20np.pi%2C%20num_samples)%0A%20%20%20%20%20%20%20%20return%20np.exp(1j%20*%20arg)%0A%20%20%20%20return%20(random_on_unit_circle%2C)%0A%0A%0A%40app.cell%0Adef%20_(mo)%3A%0A%20%20%20%20num_samples_slider%20%3D%20mo.ui.slider(%0A%20%20%20%20%20%20%20%201%2C%2015_000%2C%20value%3D500%2C%20label%3D%22Number%20of%20polynomial%20realizations%3A%20%22%0A%20%20%20%20)%0A%20%20%20%20num_samples_slider%0A%20%20%20%20return%20(num_samples_slider%2C)%0A%0A%0A%40app.cell%0Adef%20_(np%2C%20num_samples_slider%2C%20random_on_unit_circle)%3A%0A%20%20%20%20_rng%20%3D%20np.random.default_rng(0)%0A%20%20%20%20t1%20%3D%20random_on_unit_circle(_rng%2C%20num_samples_slider.value)%0A%20%20%20%20t2%20%3D%20random_on_unit_circle(_rng%2C%20num_samples_slider.value)%0A%20%20%20%20%23%20first%20dim%20ranges%20over%20samples%2C%20second%20over%20roots%0A%20%20%20%20roots%20%3D%20np.array(%0A%20%20%20%20%20%20%20%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20np.polynomial.Polynomial(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2010%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20-10%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%200%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%200%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%200%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%200%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%200%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20200%20*%20_t1**2%20-%20100%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%203200%20*%20_t2**6%20-%204800%20*%20_t2**4%20%2B%201800%20*%20_t2**2%20-%20100%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%200%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%200%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%200%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%200%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%200%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%200%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%200%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%200%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20-10%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2010%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20).roots()%0A%20%20%20%20%20%20%20%20%20%20%20%20for%20_t1%2C%20_t2%20in%20zip(t1%2C%20t2)%0A%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20)%0A%20%20%20%20roots%0A%20%20%20%20return%20roots%2C%20t2%0A%0A%0A%40app.cell%0Adef%20_(np%2C%20roots%2C%20t2)%3A%0A%20%20%20%20mask%20%3D%20t2.imag%20%3E%3D%200%0A%20%20%20%20masked_roots%20%3D%20np.concat(roots%5Bmask%2C%20%3A%5D)%0A%20%20%20%20masked_t2%20%3D%20np.repeat(t2%5Bmask%5D%2C%20repeats%3Droots.shape%5B1%5D)%0A%20%20%20%20return%20masked_roots%2C%20masked_t2%0A%0A%0A%40app.cell%0Adef%20_(go%2C%20masked_roots%2C%20masked_t2)%3A%0A%20%20%20%20_fig%20%3D%20go.Figure()%0A%20%20%20%20_fig.add_trace(%0A%20%20%20%20%20%20%20%20go.Scattergl(%0A%20%20%20%20%20%20%20%20%20%20%20%20x%3Dmasked_roots.real%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20y%3Dmasked_roots.imag%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20mode%3D%22markers%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20marker%3Ddict(size%3D1%2C%20color%3Dmasked_t2.imag)%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20)%0A%20%20%20%20_fig.update_layout(%0A%20%20%20%20%20%20%20%20xaxis%3Ddict(%0A%20%20%20%20%20%20%20%20%20%20%20%20scaleanchor%3D%22y%22%2C%20%20%23%20Anchor%20x-axis%20scale%20to%20y-axis%0A%20%20%20%20%20%20%20%20%20%20%20%20scaleratio%3D1%2C%20%20%23%20Ensure%20x-axis%20units%20are%201%3A1%20with%20y-axis%20units%0A%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20)%0A%20%20%20%20_fig%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20return%0A%0A%0Aif%20__name__%20%3D%3D%20%22__main__%22%3A%0A%20%20%20%20app.run()%0A
2254526eaea721954721e5c4c87363bafd46357fc6e19eb867e2d4dd61578b2a