0
0
mirror of http://CODE.RHODECODE.COM/u/O/O/O synced 2024-11-10 10:43:28 -05:00
O/⚪ᕤᕦ⚪ИN⚪ꖴ⚪ᙏ⚪ᗩ⚪ᴥ⚪ᕤᕦ⚪Ⓞ⚪ᴥ⚪ߦ⚪◌⚪◌⚪◌⚪◌⚪◌⚪◌⚪ߦ⚪ᴥ⚪Ⓞ⚪ᕤᕦ⚪ᴥ⚪ᗩ⚪ᙏ⚪ꖴ⚪ИN⚪ᕤᕦ⚪/⚪ИN⚪Ⓞ⚪옷⚪✤⚪人⚪ߦ⚪◌⚪◌⚪◌⚪◌⚪◌⚪◌⚪ߦ⚪人⚪✤⚪옷⚪Ⓞ⚪ИN⚪/⚪ᴥ⚪ᗱᗴ⚪✤⚪人⚪ߦ⚪ᑎ⚪ᒍᒐ⚪◌⚪◌⚪◌⚪◌⚪◌⚪◌⚪ᒍᒐ⚪ᑎ⚪ߦ⚪人⚪✤⚪ᗱᗴ⚪ᴥ⚪/BИYPI.⚪ᴥ⚪ᗱᗴ⚪✤⚪Ⓞ⚪ᙁ⚪ߦ⚪◯⚪ᗱᗴ⚪ᗯ⚪ᴥ⚪ᑎ⚪ᑐᑕ⚪◯⚪ИN⚪Ⓞ⚪ꖴ⚪✤⚪ᑐᑕ⚪ᑎ⚪ꗳ⚪◯⚪ᗱᗴ⚪ᴥ⚪ᑎ⚪✤⚪ᗩ⚪ᗯ⚪ᴥ⚪ᑎ⚪ᑐᑕ⚪◯⚪ᗝ⚪ᗱᗴ⚪ꖴ⚪ꗳ⚪ꖴ⚪ᑐᑕ⚪ᗱᗴ⚪ߦ⚪ᔓᔕ⚪◌⚪◌⚪◌⚪◌⚪◌⚪◌⚪ᔓᔕ⚪ߦ⚪ᗱᗴ⚪ᑐᑕ⚪ꖴ⚪ꗳ⚪ꖴ⚪ᗱᗴ⚪ᗝ⚪◯⚪ᑐᑕ⚪ᑎ⚪ᴥ⚪ᗯ⚪ᗩ⚪✤⚪ᑎ⚪ᴥ⚪ᗱᗴ⚪◯⚪ꗳ⚪ᑎ⚪ᑐᑕ⚪✤⚪ꖴ⚪Ⓞ⚪ИN⚪◯⚪ᑐᑕ⚪ᑎ⚪ᴥ⚪ᗯ⚪ᗱᗴ⚪◯⚪ߦ⚪ᙁ⚪Ⓞ⚪✤⚪ᗱᗴ⚪ᴥ⚪.IPYNB

1 line
25 KiB
Plaintext
Raw Normal View History

{"cells":[{"cell_type":"code","metadata":{"source_hash":"bb7e432c","execution_start":1699813215683,"execution_millis":2726,"deepnote_app_coordinates":{"h":5,"w":12,"x":0,"y":0},"deepnote_to_be_reexecuted":false,"cell_id":"1c24d01f42554ffc8072aff5dcd23315","deepnote_cell_type":"code"},"source":"import numpy as np\nimport plotly.graph_objects as go\nfrom math import *\nimport mpmath\nfrom ipywidgets import interact, widgets\n\nN_slider = widgets.IntSlider(min=1, max=16, value=8)\nRANGE_FROM_SLIDER=widgets.FloatSlider(min=0, max=4*pi, value=0*pi, step=pi/4)\nRANGE_TO_SLIDER=widgets.FloatSlider(min=0, max=4*pi, value=4*pi,step=pi/4)\ndef clamp(x):\n return max(min(1, x), -1)\ndef kappa(formula, x):\n func_dict = {fn: eval(f'lambda *args: mpmath.{fn}(*args)') for fn in dir(mpmath)}\n return float(eval(formula, {'x': x, 'clamp': clamp, **func_dict}))\ndef plot(formula='(1 - cos(((4)/2)*x))/2', RANGE_FROM=0, RANGE_TO=4*pi, N=8):\n num_points = 1+2**N\n\n # Generate x values with the specified number of points\n x_vals = np.linspace(RANGE_FROM, RANGE_TO, num_points)\n\n # Compute kappa values\n kappa_vals = np.array([kappa(formula, x_val) for x_val in x_vals])\n\n theta_vals = np.cumsum(kappa_vals) * (x_vals[1]-x_vals[0]) if num_points > 1 else np.array([0])\n x_coords_ = np.cumsum(np.cos(theta_vals)) * (x_vals[1] - x_vals[0]) if num_points > 1 else np.array([0])\n y_coords_ = np.cumsum(np.sin(theta_vals)) * (x_vals[1] - x_vals[0]) if num_points > 1 else np.array([0])\n\n # Check if the first point is zero, if not, add it manually\n if x_coords_[0] != 0 or y_coords_[0] != 0:\n x_coords = np.insert(x_coords_, 0, 0)\n y_coords = np.insert(y_coords_, 0, 0)\n else:\n x_coords = x_coords_\n y_coords = y_coords_\n\n fig = go.Figure()\n\n fig.add_trace(go.Scatter(x=x_coords, y=y_coords, mode='lines', name='Curve'))\n\n fig.update_layout(autosize=True, xaxis=dict(scaleanchor='y', scaleratio=1))\n fig.show()\n\n# Create the interactive plot\ninteract(plot, formula='(1 - cos(((4)/2)*x))/2', RANGE_FROM=RANGE_FROM_SLIDER, RANGE_TO=RANGE_TO_SLIDER, N=N_slider);","block_group":"1c24d01f42554ffc8072aff5dcd23315","execution_count":1,"outputs":[{"output_type":"clear_output"},{"data":{"text/html":"<html>\n<head><meta charset=\"utf-8\" /></head>\n<body>\n <div> <script src=\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_SVG\"></script><script type=\"text/javascript\">if (window.MathJax && window.MathJax.Hub && window.MathJax.Hub.Config) {window.MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}</script> <script type=\"text/javascript\">window.PlotlyConfig = {MathJaxConfig: 'local'};</script>\n <script charset=\"utf-8\" src=\"https://cdn.plot.ly/plotly-2.26.0.min.js\"></script> <div id=\"0864f4f9-e103-4c35-87f2-5cf680c5f794\" class=\"plotly-graph-div\" style=\"height:525px; width:100%;\"></div> <script type=\"text/javascript\"> window.PLOTLYENV=window.PLOTLYENV || {}; if (document.getElementById(\"0864f4f9-e103-4c35-87f2-5cf680c5f794\")) { Plotly.newPlot( \"0864f4f9-e103-4c35-87f2-5cf680c5f794\", [{\"mode\":\"lines\",\"name\":\"Curve\",\"x\":[0.0,0.04908738521234052,0.09817477008186463,0.14726214675677857,0.19634946542177054,0.245436547407922,0.29452292322791024,0.3436075770270656,0.3926885841849525,0.44176263495785606,0.4908244438890929,0.5398660519814511,0.5888760360612518,0.6378386470932503,0.6867329061463031,0.7355316929659873,0.7842008673736939,0.832698467662632,0.8809740324765943,0.928968093025726,0.9766118806382796,1.0238272903578864,1.070527134464086,1.11661571045146,1.1619896963540963,1.2065393727463685,1.2501501558867378,1.2927044110798869,1.3340835003368017,1.374170004812614,1.41285005129221,1.4500156640683775,1.48556705961813,1.5194148019571656,1.5514817415360636,1.5817046697747532,1.6100356342111322,1.6364428748707125,1.66091