diff options
author | Navan Chauhan <navanchauhan@gmail.com> | 2023-10-16 16:04:29 -0600 |
---|---|---|
committer | Navan Chauhan <navanchauhan@gmail.com> | 2023-10-16 16:04:29 -0600 |
commit | 48d3baf9803f673a101f6360a3d40b8211ec3e10 (patch) | |
tree | d38655908277c204704d1ac9deac408b95deb78b /docs | |
parent | 13d2fc49885c271b4b3d0235e286588b93c63a86 (diff) |
update dependencies
Diffstat (limited to 'docs')
-rw-r--r-- | docs/feed.rss | 3213 | ||||
-rw-r--r-- | docs/posts/2019-12-16-TensorFlow-Polynomial-Regression.html | 250 | ||||
-rw-r--r-- | docs/posts/2019-12-22-Fake-News-Detector.html | 2 | ||||
-rw-r--r-- | docs/posts/2020-01-16-Image-Classifier-Using-Turicreate.html | 96 | ||||
-rw-r--r-- | docs/posts/2020-08-01-Natural-Feature-Tracking-ARJS.html | 38 | ||||
-rw-r--r-- | docs/posts/2020-10-11-macOS-Virtual-Cam-OBS.html | 4 | ||||
-rw-r--r-- | docs/posts/2020-11-17-Lets-Encrypt-DuckDns.html | 46 | ||||
-rw-r--r-- | docs/posts/2020-12-1-HTML-JS-RSS-Feed.html | 340 | ||||
-rw-r--r-- | docs/posts/2021-06-27-Crude-ML-AI-Powered-Chatbot-Swift.html | 28 | ||||
-rw-r--r-- | docs/posts/2022-08-05-Why-You-No-Host.html | 2 | ||||
-rw-r--r-- | docs/posts/2023-02-08-Interact-with-siri-from-the-terminal.html | 8 | ||||
-rw-r--r-- | docs/posts/2023-04-30-n-body-simulation.html | 1065 | ||||
-rw-r--r-- | docs/posts/2023-10-04-bomb-lab.html | 1356 |
13 files changed, 3251 insertions, 3197 deletions
diff --git a/docs/feed.rss b/docs/feed.rss index fa59cca..02851bc 100644 --- a/docs/feed.rss +++ b/docs/feed.rss @@ -4,8 +4,8 @@ <title>Navan's Archive</title> <description>Rare Tips, Tricks and Posts</description> <link>https://web.navan.dev/</link><language>en</language> - <lastBuildDate>Mon, 16 Oct 2023 16:01:01 -0000</lastBuildDate> - <pubDate>Mon, 16 Oct 2023 16:01:01 -0000</pubDate> + <lastBuildDate>Mon, 16 Oct 2023 16:02:37 -0000</lastBuildDate> + <pubDate>Mon, 16 Oct 2023 16:02:37 -0000</pubDate> <ttl>250</ttl> <atom:link href="https://web.navan.dev/feed.rss" rel="self" type="application/rss+xml"/> @@ -1176,25 +1176,25 @@ me.fset me.fset3 me.iset <pre><span></span><code><span class="p"><</span><span class="nt">script</span> <span class="na">src</span><span class="o">=</span><span class="s">"https://cdn.jsdelivr.net/gh/aframevr/aframe@1c2407b26c61958baa93967b5412487cd94b290b/dist/aframe-master.min.js"</span><span class="p">></</span><span class="nt">script</span><span class="p">></span> <span class="p"><</span><span class="nt">script</span> <span class="na">src</span><span class="o">=</span><span class="s">"https://raw.githack.com/AR-js-org/AR.js/master/aframe/build/aframe-ar-nft.js"</span><span class="p">></</span><span class="nt">script</span><span class="p">></span> -<span class="p"><</span><span class="nt">style</span><span class="p">></span><span class="w"></span> -<span class="w"> </span><span class="p">.</span><span class="nc">arjs-loader</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="k">height</span><span class="p">:</span><span class="w"> </span><span class="mi">100</span><span class="kt">%</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="k">width</span><span class="p">:</span><span class="w"> </span><span class="mi">100</span><span class="kt">%</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="k">position</span><span class="p">:</span><span class="w"> </span><span class="kc">absolute</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="k">top</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="k">left</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="k">background-color</span><span class="p">:</span><span class="w"> </span><span class="nb">rgba</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="mf">0.8</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="k">z-index</span><span class="p">:</span><span class="w"> </span><span class="mi">9999</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="k">display</span><span class="p">:</span><span class="w"> </span><span class="kc">flex</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="k">justify-content</span><span class="p">:</span><span class="w"> </span><span class="kc">center</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="k">align-items</span><span class="p">:</span><span class="w"> </span><span class="kc">center</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> - -<span class="w"> </span><span class="p">.</span><span class="nc">arjs-loader</span><span class="w"> </span><span class="nt">div</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="k">text-align</span><span class="p">:</span><span class="w"> </span><span class="kc">center</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="k">font-size</span><span class="p">:</span><span class="w"> </span><span class="mf">1.25</span><span class="kt">em</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="k">color</span><span class="p">:</span><span class="w"> </span><span class="kc">white</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> +<span class="p"><</span><span class="nt">style</span><span class="p">></span> +<span class="w"> </span><span class="p">.</span><span class="nc">arjs-loader</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="k">height</span><span class="p">:</span><span class="w"> </span><span class="mi">100</span><span class="kt">%</span><span class="p">;</span> +<span class="w"> </span><span class="k">width</span><span class="p">:</span><span class="w"> </span><span class="mi">100</span><span class="kt">%</span><span class="p">;</span> +<span class="w"> </span><span class="k">position</span><span class="p">:</span><span class="w"> </span><span class="kc">absolute</span><span class="p">;</span> +<span class="w"> </span><span class="k">top</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span> +<span class="w"> </span><span class="k">left</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span> +<span class="w"> </span><span class="k">background-color</span><span class="p">:</span><span class="w"> </span><span class="nb">rgba</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="mf">0.8</span><span class="p">);</span> +<span class="w"> </span><span class="k">z-index</span><span class="p">:</span><span class="w"> </span><span class="mi">9999</span><span class="p">;</span> +<span class="w"> </span><span class="k">display</span><span class="p">:</span><span class="w"> </span><span class="kc">flex</span><span class="p">;</span> +<span class="w"> </span><span class="k">justify-content</span><span class="p">:</span><span class="w"> </span><span class="kc">center</span><span class="p">;</span> +<span class="w"> </span><span class="k">align-items</span><span class="p">:</span><span class="w"> </span><span class="kc">center</span><span class="p">;</span> +<span class="w"> </span><span class="p">}</span> + +<span class="w"> </span><span class="p">.</span><span class="nc">arjs-loader</span><span class="w"> </span><span class="nt">div</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="k">text-align</span><span class="p">:</span><span class="w"> </span><span class="kc">center</span><span class="p">;</span> +<span class="w"> </span><span class="k">font-size</span><span class="p">:</span><span class="w"> </span><span class="mf">1.25</span><span class="kt">em</span><span class="p">;</span> +<span class="w"> </span><span class="k">color</span><span class="p">:</span><span class="w"> </span><span class="kc">white</span><span class="p">;</span> +<span class="w"> </span><span class="p">}</span> <span class="p"></</span><span class="nt">style</span><span class="p">></span> <span class="p"><</span><span class="nt">body</span> <span class="na">style</span><span class="o">=</span><span class="s">"margin : 0px; overflow: hidden;"</span><span class="p">></span> @@ -1677,31 +1677,31 @@ values using the X values. We then plot it to compare the actual data and predic </div> <div class="codehilite"> -<pre><span></span><code><span class="nt">Epoch</span><span class="na"> 1000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 2000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 3000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 4000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 5000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 6000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 7000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 8000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 9000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 10000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 11000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 12000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 13000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 14000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 15000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 16000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 17000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 18000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 19000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 20000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 21000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 22000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 23000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 24000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 25000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> +<pre><span></span><code><span class="nt">Epoch</span><span class="na"> 1000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 2000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 3000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 4000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 5000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 6000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 7000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 8000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 9000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 10000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 11000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 12000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 13000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 14000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 15000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 16000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 17000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 18000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 19000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 20000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 21000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 22000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 23000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 24000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 25000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> <span class="nt">88999125000.0</span><span class="na"> 180396.42 -478869.12</span> </code></pre> </div> @@ -1742,31 +1742,31 @@ values using the X values. We then plot it to compare the actual data and predic </div> <div class="codehilite"> -<pre><span></span><code><span class="nt">Epoch</span><span class="na"> 1000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">52571360000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">1002.4456</span><span class="err"> </span><span class="nc">1097.0197</span><span class="err"> </span><span class="nc">1276.6921</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 2000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">37798890000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">1952.4263</span><span class="err"> </span><span class="nc">2130.2825</span><span class="err"> </span><span class="nc">2469.7756</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 3000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">26751185000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">2839.5825</span><span class="err"> </span><span class="nc">3081.6118</span><span class="err"> </span><span class="nc">3554.351</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 4000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">19020106000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">3644.56</span><span class="err"> </span><span class="nc">3922.9563</span><span class="err"> </span><span class="nc">4486.3135</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 5000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">14060446000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">4345.042</span><span class="err"> </span><span class="nc">4621.4233</span><span class="err"> </span><span class="nc">5212.693</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 6000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">11201084000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">4921.1855</span><span class="err"> </span><span class="nc">5148.1504</span><span class="err"> </span><span class="nc">5689.0713</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 7000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">9732740000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">5364.764</span><span class="err"> </span><span class="nc">5493.0156</span><span class="err"> </span><span class="nc">5906.754</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 8000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">9050918000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">5685.4067</span><span class="err"> </span><span class="nc">5673.182</span><span class="err"> </span><span class="nc">5902.0728</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 9000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8750394000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">5906.9814</span><span class="err"> </span><span class="nc">5724.8906</span><span class="err"> </span><span class="nc">5734.746</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 10000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8613128000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6057.3677</span><span class="err"> </span><span class="nc">5687.3364</span><span class="err"> </span><span class="nc">5461.167</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 11000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8540034600.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6160.547</span><span class="err"> </span><span class="nc">5592.3022</span><span class="err"> </span><span class="nc">5122.8633</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 12000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8490983000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6233.9175</span><span class="err"> </span><span class="nc">5462.025</span><span class="err"> </span><span class="nc">4747.111</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 13000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8450816500.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6289.048</span><span class="err"> </span><span class="nc">5310.7583</span><span class="err"> </span><span class="nc">4350.6997</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 14000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8414082000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6333.199</span><span class="err"> </span><span class="nc">5147.394</span><span class="err"> </span><span class="nc">3943.9294</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 15000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8378841600.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6370.7944</span><span class="err"> </span><span class="nc">4977.1704</span><span class="err"> </span><span class="nc">3532.476</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 16000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8344471000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6404.468</span><span class="err"> </span><span class="nc">4803.542</span><span class="err"> </span><span class="nc">3120.2087</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 17000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8310785500.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6435.365</span><span class="err"> </span><span class="nc">4628.1523</span><span class="err"> </span><span class="nc">2709.1445</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 18000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8277482000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6465.5493</span><span class="err"> </span><span class="nc">4451.833</span><span class="err"> </span><span class="nc">2300.2783</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 19000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8244650000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6494.609</span><span class="err"> </span><span class="nc">4274.826</span><span class="err"> </span><span class="nc">1894.3738</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 20000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8212349000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6522.8247</span><span class="err"> </span><span class="nc">4098.1733</span><span class="err"> </span><span class="nc">1491.9915</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 21000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8180598300.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6550.6567</span><span class="err"> </span><span class="nc">3922.7405</span><span class="err"> </span><span class="nc">1093.3868</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 22000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8149257700.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6578.489</span><span class="err"> </span><span class="nc">3747.8362</span><span class="err"> </span><span class="nc">698.53357</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 23000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8118325000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6606.1973</span><span class="err"> </span><span class="nc">3573.2742</span><span class="err"> </span><span class="nc">307.3541</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 24000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8088001000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6632.96</span><span class="err"> </span><span class="nc">3399.878</span><span class="err"> </span><span class="nc">-79.89219</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 25000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8058094600.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6659.793</span><span class="err"> </span><span class="nc">3227.2517</span><span class="err"> </span><span class="nc">-463.03156</span><span class="w"></span> +<pre><span></span><code><span class="nt">Epoch</span><span class="na"> 1000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">52571360000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">1002.4456</span><span class="err"> </span><span class="nc">1097.0197</span><span class="err"> </span><span class="nc">1276.6921</span> +<span class="nt">Epoch</span><span class="na"> 2000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">37798890000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">1952.4263</span><span class="err"> </span><span class="nc">2130.2825</span><span class="err"> </span><span class="nc">2469.7756</span> +<span class="nt">Epoch</span><span class="na"> 3000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">26751185000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">2839.5825</span><span class="err"> </span><span class="nc">3081.6118</span><span class="err"> </span><span class="nc">3554.351</span> +<span class="nt">Epoch</span><span class="na"> 4000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">19020106000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">3644.56</span><span class="err"> </span><span class="nc">3922.9563</span><span class="err"> </span><span class="nc">4486.3135</span> +<span class="nt">Epoch</span><span class="na"> 5000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">14060446000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">4345.042</span><span class="err"> </span><span class="nc">4621.4233</span><span class="err"> </span><span class="nc">5212.693</span> +<span class="nt">Epoch</span><span class="na"> 6000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">11201084000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">4921.1855</span><span class="err"> </span><span class="nc">5148.1504</span><span class="err"> </span><span class="nc">5689.0713</span> +<span class="nt">Epoch</span><span class="na"> 7000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">9732740000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">5364.764</span><span class="err"> </span><span class="nc">5493.0156</span><span class="err"> </span><span class="nc">5906.754</span> +<span class="nt">Epoch</span><span class="na"> 8000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">9050918000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">5685.4067</span><span class="err"> </span><span class="nc">5673.182</span><span class="err"> </span><span class="nc">5902.0728</span> +<span class="nt">Epoch</span><span class="na"> 9000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8750394000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">5906.9814</span><span class="err"> </span><span class="nc">5724.8906</span><span class="err"> </span><span class="nc">5734.746</span> +<span class="nt">Epoch</span><span class="na"> 10000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8613128000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6057.3677</span><span class="err"> </span><span class="nc">5687.3364</span><span class="err"> </span><span class="nc">5461.167</span> +<span class="nt">Epoch</span><span class="na"> 11000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8540034600.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6160.547</span><span class="err"> </span><span class="nc">5592.3022</span><span class="err"> </span><span class="nc">5122.8633</span> +<span class="nt">Epoch</span><span class="na"> 12000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8490983000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6233.9175</span><span class="err"> </span><span class="nc">5462.025</span><span class="err"> </span><span class="nc">4747.111</span> +<span class="nt">Epoch</span><span class="na"> 13000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8450816500.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6289.048</span><span class="err"> </span><span class="nc">5310.7583</span><span class="err"> </span><span class="nc">4350.6997</span> +<span class="nt">Epoch</span><span class="na"> 14000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8414082000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6333.199</span><span class="err"> </span><span class="nc">5147.394</span><span class="err"> </span><span class="nc">3943.9294</span> +<span class="nt">Epoch</span><span class="na"> 15000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8378841600.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6370.7944</span><span class="err"> </span><span class="nc">4977.1704</span><span class="err"> </span><span class="nc">3532.476</span> +<span class="nt">Epoch</span><span class="na"> 16000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8344471000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6404.468</span><span class="err"> </span><span class="nc">4803.542</span><span class="err"> </span><span class="nc">3120.2087</span> +<span class="nt">Epoch</span><span class="na"> 17000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8310785500.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6435.365</span><span class="err"> </span><span class="nc">4628.1523</span><span class="err"> </span><span class="nc">2709.1445</span> +<span class="nt">Epoch</span><span class="na"> 18000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8277482000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6465.5493</span><span class="err"> </span><span class="nc">4451.833</span><span class="err"> </span><span class="nc">2300.2783</span> +<span class="nt">Epoch</span><span class="na"> 19000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8244650000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6494.609</span><span class="err"> </span><span class="nc">4274.826</span><span class="err"> </span><span class="nc">1894.3738</span> +<span class="nt">Epoch</span><span class="na"> 20000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8212349000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6522.8247</span><span class="err"> </span><span class="nc">4098.1733</span><span class="err"> </span><span class="nc">1491.9915</span> +<span class="nt">Epoch</span><span class="na"> 21000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8180598300.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6550.6567</span><span class="err"> </span><span class="nc">3922.7405</span><span class="err"> </span><span class="nc">1093.3868</span> +<span class="nt">Epoch</span><span class="na"> 22000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8149257700.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6578.489</span><span class="err"> </span><span class="nc">3747.8362</span><span class="err"> </span><span class="nc">698.53357</span> +<span class="nt">Epoch</span><span class="na"> 23000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8118325000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6606.1973</span><span class="err"> </span><span class="nc">3573.2742</span><span class="err"> </span><span class="nc">307.3541</span> +<span class="nt">Epoch</span><span class="na"> 24000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8088001000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6632.96</span><span class="err"> </span><span class="nc">3399.878</span><span class="err"> </span><span class="nc">-79.89219</span> +<span class="nt">Epoch</span><span class="na"> 25000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8058094600.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6659.793</span><span class="err"> </span><span class="nc">3227.2517</span><span class="err"> </span><span class="nc">-463.03156</span> <span class="nt">8058094600.0</span><span class="na"> 6659.793 3227.2517 -463.03156</span> </code></pre> </div> @@ -1808,31 +1808,31 @@ values using the X values. We then plot it to compare the actual data and predic </div> <div class="codehilite"> -<pre><span></span><code><span class="nt">Epoch</span><span class="na"> 1000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">4279814000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">670.1527</span><span class="err"> </span><span class="nc">694.4212</span><span class="err"> </span><span class="nc">751.4653</span><span class="err"> </span><span class="nc">903.9527</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 2000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3770950400.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">742.6414</span><span class="err"> </span><span class="nc">666.3489</span><span class="err"> </span><span class="nc">636.94525</span><span class="err"> </span><span class="nc">859.2088</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 3000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3717708300.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">756.2582</span><span class="err"> </span><span class="nc">569.3339</span><span class="err"> </span><span class="nc">448.105</span><span class="err"> </span><span class="nc">748.23956</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 4000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3667464000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">769.4476</span><span class="err"> </span><span class="nc">474.0318</span><span class="err"> </span><span class="nc">265.5761</span><span class="err"> </span><span class="nc">654.75525</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 5000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3620040700.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">782.32324</span><span class="err"> </span><span class="nc">380.54272</span><span class="err"> </span><span class="nc">89.39888</span><span class="err"> </span><span class="nc">578.5136</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 6000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3575265800.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">794.8898</span><span class="err"> </span><span class="nc">288.83356</span><span class="err"> </span><span class="nc">-80.5215</span><span class="err"> </span><span class="nc">519.13654</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 7000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3532972000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">807.1608</span><span class="err"> </span><span class="nc">198.87044</span><span class="err"> </span><span class="nc">-244.31102</span><span class="err"> </span><span class="nc">476.2061</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 8000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3493009200.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">819.13513</span><span class="err"> </span><span class="nc">110.64169</span><span class="err"> </span><span class="nc">-402.0677</span><span class="err"> </span><span class="nc">449.3291</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 9000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3455228400.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">830.80255</span><span class="err"> </span><span class="nc">24.0964</span><span class="err"> </span><span class="nc">-553.92804</span><span class="err"> </span><span class="nc">438.0652</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 10000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3419475500.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">842.21594</span><span class="err"> </span><span class="nc">-60.797424</span><span class="err"> </span><span class="nc">-700.0123</span><span class="err"> </span><span class="nc">441.983</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 11000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3385625300.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">853.3363</span><span class="err"> </span><span class="nc">-144.08699</span><span class="err"> </span><span class="nc">-840.467</span><span class="err"> </span><span class="nc">460.6356</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 12000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3353544700.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">864.19135</span><span class="err"> </span><span class="nc">-225.8125</span><span class="err"> </span><span class="nc">-975.4196</span><span class="err"> </span><span class="nc">493.57703</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 13000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3323125000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">874.778</span><span class="err"> </span><span class="nc">-305.98932</span><span class="err"> </span><span class="nc">-1104.9867</span><span class="err"> </span><span class="nc">540.39465</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 14000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3294257000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">885.1007</span><span class="err"> </span><span class="nc">-384.63474</span><span class="err"> </span><span class="nc">-1229.277</span><span class="err"> </span><span class="nc">600.65607</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 15000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3266820000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">895.18823</span><span class="err"> </span><span class="nc">-461.819</span><span class="err"> </span><span class="nc">-1348.4417</span><span class="err"> </span><span class="nc">673.9051</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 16000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3240736000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">905.0128</span><span class="err"> </span><span class="nc">-537.541</span><span class="err"> </span><span class="nc">-1462.6171</span><span class="err"> </span><span class="nc">759.7118</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 17000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3215895000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">914.60065</span><span class="err"> </span><span class="nc">-611.8676</span><span class="err"> </span><span class="nc">-1571.9058</span><span class="err"> </span><span class="nc">857.6638</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 18000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3192216800.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">923.9603</span><span class="err"> </span><span class="nc">-684.8093</span><span class="err"> </span><span class="nc">-1676.4642</span><span class="err"> </span><span class="nc">967.30475</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 19000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3169632300.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">933.08594</span><span class="err"> </span><span class="nc">-756.3582</span><span class="err"> </span><span class="nc">-1776.4275</span><span class="err"> </span><span class="nc">1088.2198</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 20000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3148046300.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">941.9928</span><span class="err"> </span><span class="nc">-826.6257</span><span class="err"> </span><span class="nc">-1871.9355</span><span class="err"> </span><span class="nc">1219.9702</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 21000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3127394800.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">950.67896</span><span class="err"> </span><span class="nc">-895.6205</span><span class="err"> </span><span class="nc">-1963.0989</span><span class="err"> </span><span class="nc">1362.1665</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 22000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3107608600.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">959.1487</span><span class="err"> </span><span class="nc">-963.38116</span><span class="err"> </span><span class="nc">-2050.0586</span><span class="err"> </span><span class="nc">1514.4026</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 23000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3088618200.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">967.4355</span><span class="err"> </span><span class="nc">-1029.9625</span><span class="err"> </span><span class="nc">-2132.961</span><span class="err"> </span><span class="nc">1676.2717</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 24000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3070361300.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">975.52875</span><span class="err"> </span><span class="nc">-1095.4292</span><span class="err"> </span><span class="nc">-2211.854</span><span class="err"> </span><span class="nc">1847.4485</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 25000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3052791300.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">983.4346</span><span class="err"> </span><span class="nc">-1159.7922</span><span class="err"> </span><span class="nc">-2286.9412</span><span class="err"> </span><span class="nc">2027.4857</span><span class="w"></span> +<pre><span></span><code><span class="nt">Epoch</span><span class="na"> 1000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">4279814000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">670.1527</span><span class="err"> </span><span class="nc">694.4212</span><span class="err"> </span><span class="nc">751.4653</span><span class="err"> </span><span class="nc">903.9527</span> +<span class="nt">Epoch</span><span class="na"> 2000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3770950400.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">742.6414</span><span class="err"> </span><span class="nc">666.3489</span><span class="err"> </span><span class="nc">636.94525</span><span class="err"> </span><span class="nc">859.2088</span> +<span class="nt">Epoch</span><span class="na"> 3000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3717708300.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">756.2582</span><span class="err"> </span><span class="nc">569.3339</span><span class="err"> </span><span class="nc">448.105</span><span class="err"> </span><span class="nc">748.23956</span> +<span class="nt">Epoch</span><span class="na"> 4000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3667464000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">769.4476</span><span class="err"> </span><span class="nc">474.0318</span><span class="err"> </span><span class="nc">265.5761</span><span class="err"> </span><span class="nc">654.75525</span> +<span class="nt">Epoch</span><span class="na"> 5000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3620040700.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">782.32324</span><span class="err"> </span><span class="nc">380.54272</span><span class="err"> </span><span class="nc">89.39888</span><span class="err"> </span><span class="nc">578.5136</span> +<span class="nt">Epoch</span><span class="na"> 6000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3575265800.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">794.8898</span><span class="err"> </span><span class="nc">288.83356</span><span class="err"> </span><span class="nc">-80.5215</span><span class="err"> </span><span class="nc">519.13654</span> +<span class="nt">Epoch</span><span class="na"> 7000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3532972000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">807.1608</span><span class="err"> </span><span class="nc">198.87044</span><span class="err"> </span><span class="nc">-244.31102</span><span class="err"> </span><span class="nc">476.2061</span> +<span class="nt">Epoch</span><span class="na"> 8000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3493009200.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">819.13513</span><span class="err"> </span><span class="nc">110.64169</span><span class="err"> </span><span class="nc">-402.0677</span><span class="err"> </span><span class="nc">449.3291</span> +<span class="nt">Epoch</span><span class="na"> 9000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3455228400.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">830.80255</span><span class="err"> </span><span class="nc">24.0964</span><span class="err"> </span><span class="nc">-553.92804</span><span class="err"> </span><span class="nc">438.0652</span> +<span class="nt">Epoch</span><span class="na"> 10000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3419475500.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">842.21594</span><span class="err"> </span><span class="nc">-60.797424</span><span class="err"> </span><span class="nc">-700.0123</span><span class="err"> </span><span class="nc">441.983</span> +<span class="nt">Epoch</span><span class="na"> 11000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3385625300.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">853.3363</span><span class="err"> </span><span class="nc">-144.08699</span><span class="err"> </span><span class="nc">-840.467</span><span class="err"> </span><span class="nc">460.6356</span> +<span class="nt">Epoch</span><span class="na"> 12000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3353544700.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">864.19135</span><span class="err"> </span><span class="nc">-225.8125</span><span class="err"> </span><span class="nc">-975.4196</span><span class="err"> </span><span class="nc">493.57703</span> +<span class="nt">Epoch</span><span class="na"> 13000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3323125000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">874.778</span><span class="err"> </span><span class="nc">-305.98932</span><span class="err"> </span><span class="nc">-1104.9867</span><span class="err"> </span><span class="nc">540.39465</span> +<span class="nt">Epoch</span><span class="na"> 14000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3294257000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">885.1007</span><span class="err"> </span><span class="nc">-384.63474</span><span class="err"> </span><span class="nc">-1229.277</span><span class="err"> </span><span class="nc">600.65607</span> +<span class="nt">Epoch</span><span class="na"> 15000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3266820000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">895.18823</span><span class="err"> </span><span class="nc">-461.819</span><span class="err"> </span><span class="nc">-1348.4417</span><span class="err"> </span><span class="nc">673.9051</span> +<span class="nt">Epoch</span><span class="na"> 16000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3240736000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">905.0128</span><span class="err"> </span><span class="nc">-537.541</span><span class="err"> </span><span class="nc">-1462.6171</span><span class="err"> </span><span class="nc">759.7118</span> +<span class="nt">Epoch</span><span class="na"> 17000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3215895000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">914.60065</span><span class="err"> </span><span class="nc">-611.8676</span><span class="err"> </span><span class="nc">-1571.9058</span><span class="err"> </span><span class="nc">857.6638</span> +<span class="nt">Epoch</span><span class="na"> 18000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3192216800.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">923.9603</span><span class="err"> </span><span class="nc">-684.8093</span><span class="err"> </span><span class="nc">-1676.4642</span><span class="err"> </span><span class="nc">967.30475</span> +<span class="nt">Epoch</span><span class="na"> 19000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3169632300.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">933.08594</span><span class="err"> </span><span class="nc">-756.3582</span><span class="err"> </span><span class="nc">-1776.4275</span><span class="err"> </span><span class="nc">1088.2198</span> +<span class="nt">Epoch</span><span class="na"> 20000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3148046300.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">941.9928</span><span class="err"> </span><span class="nc">-826.6257</span><span class="err"> </span><span class="nc">-1871.9355</span><span class="err"> </span><span class="nc">1219.9702</span> +<span class="nt">Epoch</span><span class="na"> 21000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3127394800.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">950.67896</span><span class="err"> </span><span class="nc">-895.6205</span><span class="err"> </span><span class="nc">-1963.0989</span><span class="err"> </span><span class="nc">1362.1665</span> +<span class="nt">Epoch</span><span class="na"> 22000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3107608600.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">959.1487</span><span class="err"> </span><span class="nc">-963.38116</span><span class="err"> </span><span class="nc">-2050.0586</span><span class="err"> </span><span class="nc">1514.4026</span> +<span class="nt">Epoch</span><span class="na"> 23000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3088618200.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">967.4355</span><span class="err"> </span><span class="nc">-1029.9625</span><span class="err"> </span><span class="nc">-2132.961</span><span class="err"> </span><span class="nc">1676.2717</span> +<span class="nt">Epoch</span><span class="na"> 24000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3070361300.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">975.52875</span><span class="err"> </span><span class="nc">-1095.4292</span><span class="err"> </span><span class="nc">-2211.854</span><span class="err"> </span><span class="nc">1847.4485</span> +<span class="nt">Epoch</span><span class="na"> 25000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3052791300.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">983.4346</span><span class="err"> </span><span class="nc">-1159.7922</span><span class="err"> </span><span class="nc">-2286.9412</span><span class="err"> </span><span class="nc">2027.4857</span> <span class="nt">3052791300.0</span><span class="na"> 983.4346 -1159.7922 -2286.9412 2027.4857</span> </code></pre> </div> @@ -1875,31 +1875,31 @@ values using the X values. We then plot it to compare the actual data and predic </div> <div class="codehilite"> -<pre><span></span><code><span class="nt">Epoch</span><span class="na"> 1000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1902632600.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">84.48304</span><span class="err"> </span><span class="nc">52.210594</span><span class="err"> </span><span class="nc">54.791424</span><span class="err"> </span><span class="nc">142.51952</span><span class="err"> </span><span class="nc">512.0343</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 2000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1854316200.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">88.998955</span><span class="err"> </span><span class="nc">13.073557</span><span class="err"> </span><span class="nc">14.276088</span><span class="err"> </span><span class="nc">223.55667</span><span class="err"> </span><span class="nc">1056.4655</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 3000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1812812400.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">92.9462</span><span class="err"> </span><span class="nc">-22.331177</span><span class="err"> </span><span class="nc">-15.262934</span><span class="err"> </span><span class="nc">327.41858</span><span class="err"> </span><span class="nc">1634.9054</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 4000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1775716000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">96.42522</span><span class="err"> </span><span class="nc">-54.64535</span><span class="err"> </span><span class="nc">-35.829437</span><span class="err"> </span><span class="nc">449.5028</span><span class="err"> </span><span class="nc">2239.1392</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 5000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1741494100.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">99.524734</span><span class="err"> </span><span class="nc">-84.43976</span><span class="err"> </span><span class="nc">-49.181057</span><span class="err"> </span><span class="nc">585.85876</span><span class="err"> </span><span class="nc">2862.4915</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 6000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1709199600.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">102.31984</span><span class="err"> </span><span class="nc">-112.19895</span><span class="err"> </span><span class="nc">-56.808075</span><span class="err"> </span><span class="nc">733.1876</span><span class="err"> </span><span class="nc">3499.6199</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 7000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1678261800.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">104.87324</span><span class="err"> </span><span class="nc">-138.32709</span><span class="err"> </span><span class="nc">-59.9442</span><span class="err"> </span><span class="nc">888.79626</span><span class="err"> </span><span class="nc">4146.2944</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 8000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1648340600.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">107.23536</span><span class="err"> </span><span class="nc">-163.15173</span><span class="err"> </span><span class="nc">-59.58964</span><span class="err"> </span><span class="nc">1050.524</span><span class="err"> </span><span class="nc">4798.979</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 9000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1619243400.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">109.44742</span><span class="err"> </span><span class="nc">-186.9409</span><span class="err"> </span><span class="nc">-56.53944</span><span class="err"> </span><span class="nc">1216.6432</span><span class="err"> </span><span class="nc">5454.9463</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 10000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1590821900.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">111.54233</span><span class="err"> </span><span class="nc">-209.91287</span><span class="err"> </span><span class="nc">-51.423084</span><span class="err"> </span><span class="nc">1385.8513</span><span class="err"> </span><span class="nc">6113.5137</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 11000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1563042200.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">113.54405</span><span class="err"> </span><span class="nc">-232.21953</span><span class="err"> </span><span class="nc">-44.73371</span><span class="err"> </span><span class="nc">1557.1084</span><span class="err"> </span><span class="nc">6771.7046</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 12000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1535855600.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">115.471565</span><span class="err"> </span><span class="nc">-253.9838</span><span class="err"> </span><span class="nc">-36.851135</span><span class="err"> </span><span class="nc">1729.535</span><span class="err"> </span><span class="nc">7429.069</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 13000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1509255300.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">117.33939</span><span class="err"> </span><span class="nc">-275.29697</span><span class="err"> </span><span class="nc">-28.0714</span><span class="err"> </span><span class="nc">1902.5308</span><span class="err"> </span><span class="nc">8083.9634</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 14000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1483227000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">119.1605</span><span class="err"> </span><span class="nc">-296.2472</span><span class="err"> </span><span class="nc">-18.618649</span><span class="err"> </span><span class="nc">2075.6094</span><span class="err"> </span><span class="nc">8735.381</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 15000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1457726700.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">120.94584</span><span class="err"> </span><span class="nc">-316.915</span><span class="err"> </span><span class="nc">-8.650095</span><span class="err"> </span><span class="nc">2248.3247</span><span class="err"> </span><span class="nc">9384.197</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 16000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1432777300.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">122.69806</span><span class="err"> </span><span class="nc">-337.30704</span><span class="err"> </span><span class="nc">1.7027153</span><span class="err"> </span><span class="nc">2420.5771</span><span class="err"> </span><span class="nc">10028.871</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 17000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1408365000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">124.42179</span><span class="err"> </span><span class="nc">-357.45245</span><span class="err"> </span><span class="nc">12.33499</span><span class="err"> </span><span class="nc">2592.2983</span><span class="err"> </span><span class="nc">10669.157</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 18000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1384480000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">126.12332</span><span class="err"> </span><span class="nc">-377.39734</span><span class="err"> </span><span class="nc">23.168756</span><span class="err"> </span><span class="nc">2763.0933</span><span class="err"> </span><span class="nc">11305.027</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 19000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1361116800.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">127.80568</span><span class="err"> </span><span class="nc">-397.16415</span><span class="err"> </span><span class="nc">34.160156</span><span class="err"> </span><span class="nc">2933.0452</span><span class="err"> </span><span class="nc">11935.669</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 20000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1338288100.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">129.4674</span><span class="err"> </span><span class="nc">-416.72803</span><span class="err"> </span><span class="nc">45.259155</span><span class="err"> </span><span class="nc">3101.7727</span><span class="err"> </span><span class="nc">12561.179</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 21000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1315959700.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">131.11403</span><span class="err"> </span><span class="nc">-436.14285</span><span class="err"> </span><span class="nc">56.4436</span><span class="err"> </span><span class="nc">3269.3142</span><span class="err"> </span><span class="nc">13182.058</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 22000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1294164700.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">132.74377</span><span class="err"> </span><span class="nc">-455.3779</span><span class="err"> </span><span class="nc">67.6757</span><span class="err"> </span><span class="nc">3435.3833</span><span class="err"> </span><span class="nc">13796.807</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 23000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1272863600.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">134.35779</span><span class="err"> </span><span class="nc">-474.45316</span><span class="err"> </span><span class="nc">78.96117</span><span class="err"> </span><span class="nc">3600.264</span><span class="err"> </span><span class="nc">14406.58</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 24000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1252052600.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">135.9583</span><span class="err"> </span><span class="nc">-493.38254</span><span class="err"> </span><span class="nc">90.268616</span><span class="err"> </span><span class="nc">3764.0078</span><span class="err"> </span><span class="nc">15010.481</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 25000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1231713700.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">137.54753</span><span class="err"> </span><span class="nc">-512.1876</span><span class="err"> </span><span class="nc">101.59372</span><span class="err"> </span><span class="nc">3926.4897</span><span class="err"> </span><span class="nc">15609.368</span><span class="w"></span> +<pre><span></span><code><span class="nt">Epoch</span><span class="na"> 1000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1902632600.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">84.48304</span><span class="err"> </span><span class="nc">52.210594</span><span class="err"> </span><span class="nc">54.791424</span><span class="err"> </span><span class="nc">142.51952</span><span class="err"> </span><span class="nc">512.0343</span> +<span class="nt">Epoch</span><span class="na"> 2000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1854316200.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">88.998955</span><span class="err"> </span><span class="nc">13.073557</span><span class="err"> </span><span class="nc">14.276088</span><span class="err"> </span><span class="nc">223.55667</span><span class="err"> </span><span class="nc">1056.4655</span> +<span class="nt">Epoch</span><span class="na"> 3000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1812812400.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">92.9462</span><span class="err"> </span><span class="nc">-22.331177</span><span class="err"> </span><span class="nc">-15.262934</span><span class="err"> </span><span class="nc">327.41858</span><span class="err"> </span><span class="nc">1634.9054</span> +<span class="nt">Epoch</span><span class="na"> 4000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1775716000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">96.42522</span><span class="err"> </span><span class="nc">-54.64535</span><span class="err"> </span><span class="nc">-35.829437</span><span class="err"> </span><span class="nc">449.5028</span><span class="err"> </span><span class="nc">2239.1392</span> +<span class="nt">Epoch</span><span class="na"> 5000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1741494100.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">99.524734</span><span class="err"> </span><span class="nc">-84.43976</span><span class="err"> </span><span class="nc">-49.181057</span><span class="err"> </span><span class="nc">585.85876</span><span class="err"> </span><span class="nc">2862.4915</span> +<span class="nt">Epoch</span><span class="na"> 6000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1709199600.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">102.31984</span><span class="err"> </span><span class="nc">-112.19895</span><span class="err"> </span><span class="nc">-56.808075</span><span class="err"> </span><span class="nc">733.1876</span><span class="err"> </span><span class="nc">3499.6199</span> +<span class="nt">Epoch</span><span class="na"> 7000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1678261800.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">104.87324</span><span class="err"> </span><span class="nc">-138.32709</span><span class="err"> </span><span class="nc">-59.9442</span><span class="err"> </span><span class="nc">888.79626</span><span class="err"> </span><span class="nc">4146.2944</span> +<span class="nt">Epoch</span><span class="na"> 8000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1648340600.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">107.23536</span><span class="err"> </span><span class="nc">-163.15173</span><span class="err"> </span><span class="nc">-59.58964</span><span class="err"> </span><span class="nc">1050.524</span><span class="err"> </span><span class="nc">4798.979</span> +<span class="nt">Epoch</span><span class="na"> 9000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1619243400.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">109.44742</span><span class="err"> </span><span class="nc">-186.9409</span><span class="err"> </span><span class="nc">-56.53944</span><span class="err"> </span><span class="nc">1216.6432</span><span class="err"> </span><span class="nc">5454.9463</span> +<span class="nt">Epoch</span><span class="na"> 10000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1590821900.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">111.54233</span><span class="err"> </span><span class="nc">-209.91287</span><span class="err"> </span><span class="nc">-51.423084</span><span class="err"> </span><span class="nc">1385.8513</span><span class="err"> </span><span class="nc">6113.5137</span> +<span class="nt">Epoch</span><span class="na"> 11000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1563042200.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">113.54405</span><span class="err"> </span><span class="nc">-232.21953</span><span class="err"> </span><span class="nc">-44.73371</span><span class="err"> </span><span class="nc">1557.1084</span><span class="err"> </span><span class="nc">6771.7046</span> +<span class="nt">Epoch</span><span class="na"> 12000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1535855600.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">115.471565</span><span class="err"> </span><span class="nc">-253.9838</span><span class="err"> </span><span class="nc">-36.851135</span><span class="err"> </span><span class="nc">1729.535</span><span class="err"> </span><span class="nc">7429.069</span> +<span class="nt">Epoch</span><span class="na"> 13000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1509255300.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">117.33939</span><span class="err"> </span><span class="nc">-275.29697</span><span class="err"> </span><span class="nc">-28.0714</span><span class="err"> </span><span class="nc">1902.5308</span><span class="err"> </span><span class="nc">8083.9634</span> +<span class="nt">Epoch</span><span class="na"> 14000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1483227000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">119.1605</span><span class="err"> </span><span class="nc">-296.2472</span><span class="err"> </span><span class="nc">-18.618649</span><span class="err"> </span><span class="nc">2075.6094</span><span class="err"> </span><span class="nc">8735.381</span> +<span class="nt">Epoch</span><span class="na"> 15000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1457726700.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">120.94584</span><span class="err"> </span><span class="nc">-316.915</span><span class="err"> </span><span class="nc">-8.650095</span><span class="err"> </span><span class="nc">2248.3247</span><span class="err"> </span><span class="nc">9384.197</span> +<span class="nt">Epoch</span><span class="na"> 16000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1432777300.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">122.69806</span><span class="err"> </span><span class="nc">-337.30704</span><span class="err"> </span><span class="nc">1.7027153</span><span class="err"> </span><span class="nc">2420.5771</span><span class="err"> </span><span class="nc">10028.871</span> +<span class="nt">Epoch</span><span class="na"> 17000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1408365000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">124.42179</span><span class="err"> </span><span class="nc">-357.45245</span><span class="err"> </span><span class="nc">12.33499</span><span class="err"> </span><span class="nc">2592.2983</span><span class="err"> </span><span class="nc">10669.157</span> +<span class="nt">Epoch</span><span class="na"> 18000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1384480000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">126.12332</span><span class="err"> </span><span class="nc">-377.39734</span><span class="err"> </span><span class="nc">23.168756</span><span class="err"> </span><span class="nc">2763.0933</span><span class="err"> </span><span class="nc">11305.027</span> +<span class="nt">Epoch</span><span class="na"> 19000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1361116800.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">127.80568</span><span class="err"> </span><span class="nc">-397.16415</span><span class="err"> </span><span class="nc">34.160156</span><span class="err"> </span><span class="nc">2933.0452</span><span class="err"> </span><span class="nc">11935.669</span> +<span class="nt">Epoch</span><span class="na"> 20000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1338288100.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">129.4674</span><span class="err"> </span><span class="nc">-416.72803</span><span class="err"> </span><span class="nc">45.259155</span><span class="err"> </span><span class="nc">3101.7727</span><span class="err"> </span><span class="nc">12561.179</span> +<span class="nt">Epoch</span><span class="na"> 21000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1315959700.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">131.11403</span><span class="err"> </span><span class="nc">-436.14285</span><span class="err"> </span><span class="nc">56.4436</span><span class="err"> </span><span class="nc">3269.3142</span><span class="err"> </span><span class="nc">13182.058</span> +<span class="nt">Epoch</span><span class="na"> 22000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1294164700.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">132.74377</span><span class="err"> </span><span class="nc">-455.3779</span><span class="err"> </span><span class="nc">67.6757</span><span class="err"> </span><span class="nc">3435.3833</span><span class="err"> </span><span class="nc">13796.807</span> +<span class="nt">Epoch</span><span class="na"> 23000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1272863600.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">134.35779</span><span class="err"> </span><span class="nc">-474.45316</span><span class="err"> </span><span class="nc">78.96117</span><span class="err"> </span><span class="nc">3600.264</span><span class="err"> </span><span class="nc">14406.58</span> +<span class="nt">Epoch</span><span class="na"> 24000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1252052600.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">135.9583</span><span class="err"> </span><span class="nc">-493.38254</span><span class="err"> </span><span class="nc">90.268616</span><span class="err"> </span><span class="nc">3764.0078</span><span class="err"> </span><span class="nc">15010.481</span> +<span class="nt">Epoch</span><span class="na"> 25000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1231713700.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">137.54753</span><span class="err"> </span><span class="nc">-512.1876</span><span class="err"> </span><span class="nc">101.59372</span><span class="err"> </span><span class="nc">3926.4897</span><span class="err"> </span><span class="nc">15609.368</span> <span class="nt">1231713700.0</span><span class="na"> 137.54753 -512.1876 101.59372 3926.4897 15609.368</span> </code></pre> </div> @@ -1941,31 +1941,31 @@ values using the X values. We then plot it to compare the actual data and predic </div> <div class="codehilite"> -<pre><span></span><code><span class="nt">Epoch</span><span class="na"> 1000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1409200100.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">7.949472</span><span class="err"> </span><span class="nc">7.46219</span><span class="err"> </span><span class="nc">55.626034</span><span class="err"> </span><span class="nc">184.29028</span><span class="err"> </span><span class="nc">484.00223</span><span class="err"> </span><span class="nc">1024.0083</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 2000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1306882400.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">8.732181</span><span class="err"> </span><span class="nc">-4.0085897</span><span class="err"> </span><span class="nc">73.25298</span><span class="err"> </span><span class="nc">315.90103</span><span class="err"> </span><span class="nc">904.08887</span><span class="err"> </span><span class="nc">2004.9749</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 3000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1212606000.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">9.732249</span><span class="err"> </span><span class="nc">-16.90125</span><span class="err"> </span><span class="nc">86.28379</span><span class="err"> </span><span class="nc">437.06552</span><span class="err"> </span><span class="nc">1305.055</span><span class="err"> </span><span class="nc">2966.2188</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 4000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1123640400.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">10.74851</span><span class="err"> </span><span class="nc">-29.82692</span><span class="err"> </span><span class="nc">98.59997</span><span class="err"> </span><span class="nc">555.331</span><span class="err"> </span><span class="nc">1698.4631</span><span class="err"> </span><span class="nc">3917.9155</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 5000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1039694300.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">11.75426</span><span class="err"> </span><span class="nc">-42.598194</span><span class="err"> </span><span class="nc">110.698326</span><span class="err"> </span><span class="nc">671.64355</span><span class="err"> </span><span class="nc">2085.5513</span><span class="err"> </span><span class="nc">4860.8535</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 6000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">960663550.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">12.745439</span><span class="err"> </span><span class="nc">-55.18337</span><span class="err"> </span><span class="nc">122.644936</span><span class="err"> </span><span class="nc">786.00214</span><span class="err"> </span><span class="nc">2466.1638</span><span class="err"> </span><span class="nc">5794.3735</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 7000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">886438340.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">13.721028</span><span class="err"> </span><span class="nc">-67.57168</span><span class="err"> </span><span class="nc">134.43822</span><span class="err"> </span><span class="nc">898.3691</span><span class="err"> </span><span class="nc">2839.9958</span><span class="err"> </span><span class="nc">6717.659</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 8000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">816913100.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">14.679965</span><span class="err"> </span><span class="nc">-79.75113</span><span class="err"> </span><span class="nc">146.07385</span><span class="err"> </span><span class="nc">1008.66895</span><span class="err"> </span><span class="nc">3206.6692</span><span class="err"> </span><span class="nc">7629.812</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 9000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">751971500.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">15.62181</span><span class="err"> </span><span class="nc">-91.71608</span><span class="err"> </span><span class="nc">157.55713</span><span class="err"> </span><span class="nc">1116.7715</span><span class="err"> </span><span class="nc">3565.8323</span><span class="err"> </span><span class="nc">8529.976</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 10000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">691508740.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">16.545347</span><span class="err"> </span><span class="nc">-103.4531</span><span class="err"> </span><span class="nc">168.88321</span><span class="err"> </span><span class="nc">1222.6348</span><span class="err"> </span><span class="nc">3916.9785</span><span class="err"> </span><span class="nc">9416.236</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 11000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">635382000.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">17.450052</span><span class="err"> </span><span class="nc">-114.954254</span><span class="err"> </span><span class="nc">180.03932</span><span class="err"> </span><span class="nc">1326.1565</span><span class="err"> </span><span class="nc">4259.842</span><span class="err"> </span><span class="nc">10287.99</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 12000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">583477250.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">18.334944</span><span class="err"> </span><span class="nc">-126.20821</span><span class="err"> </span><span class="nc">191.02948</span><span class="err"> </span><span class="nc">1427.2095</span><span class="err"> </span><span class="nc">4593.8</span><span class="err"> </span><span class="nc">11143.449</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 13000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">535640400.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">19.198917</span><span class="err"> </span><span class="nc">-137.20206</span><span class="err"> </span><span class="nc">201.84718</span><span class="err"> </span><span class="nc">1525.6926</span><span class="err"> </span><span class="nc">4918.5327</span><span class="err"> </span><span class="nc">11981.633</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 14000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">491722240.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">20.041153</span><span class="err"> </span><span class="nc">-147.92719</span><span class="err"> </span><span class="nc">212.49709</span><span class="err"> </span><span class="nc">1621.5496</span><span class="err"> </span><span class="nc">5233.627</span><span class="err"> </span><span class="nc">12800.468</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 15000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">451559520.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">20.860966</span><span class="err"> </span><span class="nc">-158.37456</span><span class="err"> </span><span class="nc">222.97133</span><span class="err"> </span><span class="nc">1714.7141</span><span class="err"> </span><span class="nc">5538.676</span><span class="err"> </span><span class="nc">13598.337</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 16000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">414988960.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">21.657421</span><span class="err"> </span><span class="nc">-168.53406</span><span class="err"> </span><span class="nc">233.27422</span><span class="err"> </span><span class="nc">1805.0874</span><span class="err"> </span><span class="nc">5833.1978</span><span class="err"> </span><span class="nc">14373.658</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 17000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">381837920.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">22.429693</span><span class="err"> </span><span class="nc">-178.39536</span><span class="err"> </span><span class="nc">243.39914</span><span class="err"> </span><span class="nc">1892.5883</span><span class="err"> </span><span class="nc">6116.847</span><span class="err"> </span><span class="nc">15124.394</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 18000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">351931300.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">23.176882</span><span class="err"> </span><span class="nc">-187.94789</span><span class="err"> </span><span class="nc">253.3445</span><span class="err"> </span><span class="nc">1977.137</span><span class="err"> </span><span class="nc">6389.117</span><span class="err"> </span><span class="nc">15848.417</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 19000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">325074400.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">23.898485</span><span class="err"> </span><span class="nc">-197.18741</span><span class="err"> </span><span class="nc">263.12512</span><span class="err"> </span><span class="nc">2058.6716</span><span class="err"> </span><span class="nc">6649.8037</span><span class="err"> </span><span class="nc">16543.95</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 20000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">301073570.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">24.593851</span><span class="err"> </span><span class="nc">-206.10497</span><span class="err"> </span><span class="nc">272.72385</span><span class="err"> </span><span class="nc">2137.1797</span><span class="err"> </span><span class="nc">6898.544</span><span class="err"> </span><span class="nc">17209.367</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 21000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">279727000.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">25.262104</span><span class="err"> </span><span class="nc">-214.69217</span><span class="err"> </span><span class="nc">282.14642</span><span class="err"> </span><span class="nc">2212.6372</span><span class="err"> </span><span class="nc">7135.217</span><span class="err"> </span><span class="nc">17842.854</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 22000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">260845550.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">25.903376</span><span class="err"> </span><span class="nc">-222.94969</span><span class="err"> </span><span class="nc">291.4003</span><span class="err"> </span><span class="nc">2284.9844</span><span class="err"> </span><span class="nc">7359.4644</span><span class="err"> </span><span class="nc">18442.408</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 23000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">244218030.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">26.517094</span><span class="err"> </span><span class="nc">-230.8697</span><span class="err"> </span><span class="nc">300.45532</span><span class="err"> </span><span class="nc">2354.3003</span><span class="err"> </span><span class="nc">7571.261</span><span class="err"> </span><span class="nc">19007.49</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 24000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">229660080.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">27.102589</span><span class="err"> </span><span class="nc">-238.44817</span><span class="err"> </span><span class="nc">309.35342</span><span class="err"> </span><span class="nc">2420.4185</span><span class="err"> </span><span class="nc">7770.5728</span><span class="err"> </span><span class="nc">19536.19</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 25000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">216972400.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">27.660324</span><span class="err"> </span><span class="nc">-245.69016</span><span class="err"> </span><span class="nc">318.10062</span><span class="err"> </span><span class="nc">2483.3608</span><span class="err"> </span><span class="nc">7957.354</span><span class="err"> </span><span class="nc">20027.707</span><span class="w"></span> +<pre><span></span><code><span class="nt">Epoch</span><span class="na"> 1000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1409200100.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">7.949472</span><span class="err"> </span><span class="nc">7.46219</span><span class="err"> </span><span class="nc">55.626034</span><span class="err"> </span><span class="nc">184.29028</span><span class="err"> </span><span class="nc">484.00223</span><span class="err"> </span><span class="nc">1024.0083</span> +<span class="nt">Epoch</span><span class="na"> 2000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1306882400.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">8.732181</span><span class="err"> </span><span class="nc">-4.0085897</span><span class="err"> </span><span class="nc">73.25298</span><span class="err"> </span><span class="nc">315.90103</span><span class="err"> </span><span class="nc">904.08887</span><span class="err"> </span><span class="nc">2004.9749</span> +<span class="nt">Epoch</span><span class="na"> 3000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1212606000.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">9.732249</span><span class="err"> </span><span class="nc">-16.90125</span><span class="err"> </span><span class="nc">86.28379</span><span class="err"> </span><span class="nc">437.06552</span><span class="err"> </span><span class="nc">1305.055</span><span class="err"> </span><span class="nc">2966.2188</span> +<span class="nt">Epoch</span><span class="na"> 4000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1123640400.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">10.74851</span><span class="err"> </span><span class="nc">-29.82692</span><span class="err"> </span><span class="nc">98.59997</span><span class="err"> </span><span class="nc">555.331</span><span class="err"> </span><span class="nc">1698.4631</span><span class="err"> </span><span class="nc">3917.9155</span> +<span class="nt">Epoch</span><span class="na"> 5000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1039694300.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">11.75426</span><span class="err"> </span><span class="nc">-42.598194</span><span class="err"> </span><span class="nc">110.698326</span><span class="err"> </span><span class="nc">671.64355</span><span class="err"> </span><span class="nc">2085.5513</span><span class="err"> </span><span class="nc">4860.8535</span> +<span class="nt">Epoch</span><span class="na"> 6000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">960663550.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">12.745439</span><span class="err"> </span><span class="nc">-55.18337</span><span class="err"> </span><span class="nc">122.644936</span><span class="err"> </span><span class="nc">786.00214</span><span class="err"> </span><span class="nc">2466.1638</span><span class="err"> </span><span class="nc">5794.3735</span> +<span class="nt">Epoch</span><span class="na"> 7000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">886438340.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">13.721028</span><span class="err"> </span><span class="nc">-67.57168</span><span class="err"> </span><span class="nc">134.43822</span><span class="err"> </span><span class="nc">898.3691</span><span class="err"> </span><span class="nc">2839.9958</span><span class="err"> </span><span class="nc">6717.659</span> +<span class="nt">Epoch</span><span class="na"> 8000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">816913100.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">14.679965</span><span class="err"> </span><span class="nc">-79.75113</span><span class="err"> </span><span class="nc">146.07385</span><span class="err"> </span><span class="nc">1008.66895</span><span class="err"> </span><span class="nc">3206.6692</span><span class="err"> </span><span class="nc">7629.812</span> +<span class="nt">Epoch</span><span class="na"> 9000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">751971500.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">15.62181</span><span class="err"> </span><span class="nc">-91.71608</span><span class="err"> </span><span class="nc">157.55713</span><span class="err"> </span><span class="nc">1116.7715</span><span class="err"> </span><span class="nc">3565.8323</span><span class="err"> </span><span class="nc">8529.976</span> +<span class="nt">Epoch</span><span class="na"> 10000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">691508740.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">16.545347</span><span class="err"> </span><span class="nc">-103.4531</span><span class="err"> </span><span class="nc">168.88321</span><span class="err"> </span><span class="nc">1222.6348</span><span class="err"> </span><span class="nc">3916.9785</span><span class="err"> </span><span class="nc">9416.236</span> +<span class="nt">Epoch</span><span class="na"> 11000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">635382000.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">17.450052</span><span class="err"> </span><span class="nc">-114.954254</span><span class="err"> </span><span class="nc">180.03932</span><span class="err"> </span><span class="nc">1326.1565</span><span class="err"> </span><span class="nc">4259.842</span><span class="err"> </span><span class="nc">10287.99</span> +<span class="nt">Epoch</span><span class="na"> 12000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">583477250.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">18.334944</span><span class="err"> </span><span class="nc">-126.20821</span><span class="err"> </span><span class="nc">191.02948</span><span class="err"> </span><span class="nc">1427.2095</span><span class="err"> </span><span class="nc">4593.8</span><span class="err"> </span><span class="nc">11143.449</span> +<span class="nt">Epoch</span><span class="na"> 13000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">535640400.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">19.198917</span><span class="err"> </span><span class="nc">-137.20206</span><span class="err"> </span><span class="nc">201.84718</span><span class="err"> </span><span class="nc">1525.6926</span><span class="err"> </span><span class="nc">4918.5327</span><span class="err"> </span><span class="nc">11981.633</span> +<span class="nt">Epoch</span><span class="na"> 14000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">491722240.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">20.041153</span><span class="err"> </span><span class="nc">-147.92719</span><span class="err"> </span><span class="nc">212.49709</span><span class="err"> </span><span class="nc">1621.5496</span><span class="err"> </span><span class="nc">5233.627</span><span class="err"> </span><span class="nc">12800.468</span> +<span class="nt">Epoch</span><span class="na"> 15000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">451559520.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">20.860966</span><span class="err"> </span><span class="nc">-158.37456</span><span class="err"> </span><span class="nc">222.97133</span><span class="err"> </span><span class="nc">1714.7141</span><span class="err"> </span><span class="nc">5538.676</span><span class="err"> </span><span class="nc">13598.337</span> +<span class="nt">Epoch</span><span class="na"> 16000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">414988960.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">21.657421</span><span class="err"> </span><span class="nc">-168.53406</span><span class="err"> </span><span class="nc">233.27422</span><span class="err"> </span><span class="nc">1805.0874</span><span class="err"> </span><span class="nc">5833.1978</span><span class="err"> </span><span class="nc">14373.658</span> +<span class="nt">Epoch</span><span class="na"> 17000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">381837920.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">22.429693</span><span class="err"> </span><span class="nc">-178.39536</span><span class="err"> </span><span class="nc">243.39914</span><span class="err"> </span><span class="nc">1892.5883</span><span class="err"> </span><span class="nc">6116.847</span><span class="err"> </span><span class="nc">15124.394</span> +<span class="nt">Epoch</span><span class="na"> 18000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">351931300.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">23.176882</span><span class="err"> </span><span class="nc">-187.94789</span><span class="err"> </span><span class="nc">253.3445</span><span class="err"> </span><span class="nc">1977.137</span><span class="err"> </span><span class="nc">6389.117</span><span class="err"> </span><span class="nc">15848.417</span> +<span class="nt">Epoch</span><span class="na"> 19000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">325074400.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">23.898485</span><span class="err"> </span><span class="nc">-197.18741</span><span class="err"> </span><span class="nc">263.12512</span><span class="err"> </span><span class="nc">2058.6716</span><span class="err"> </span><span class="nc">6649.8037</span><span class="err"> </span><span class="nc">16543.95</span> +<span class="nt">Epoch</span><span class="na"> 20000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">301073570.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">24.593851</span><span class="err"> </span><span class="nc">-206.10497</span><span class="err"> </span><span class="nc">272.72385</span><span class="err"> </span><span class="nc">2137.1797</span><span class="err"> </span><span class="nc">6898.544</span><span class="err"> </span><span class="nc">17209.367</span> +<span class="nt">Epoch</span><span class="na"> 21000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">279727000.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">25.262104</span><span class="err"> </span><span class="nc">-214.69217</span><span class="err"> </span><span class="nc">282.14642</span><span class="err"> </span><span class="nc">2212.6372</span><span class="err"> </span><span class="nc">7135.217</span><span class="err"> </span><span class="nc">17842.854</span> +<span class="nt">Epoch</span><span class="na"> 22000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">260845550.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">25.903376</span><span class="err"> </span><span class="nc">-222.94969</span><span class="err"> </span><span class="nc">291.4003</span><span class="err"> </span><span class="nc">2284.9844</span><span class="err"> </span><span class="nc">7359.4644</span><span class="err"> </span><span class="nc">18442.408</span> +<span class="nt">Epoch</span><span class="na"> 23000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">244218030.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">26.517094</span><span class="err"> </span><span class="nc">-230.8697</span><span class="err"> </span><span class="nc">300.45532</span><span class="err"> </span><span class="nc">2354.3003</span><span class="err"> </span><span class="nc">7571.261</span><span class="err"> </span><span class="nc">19007.49</span> +<span class="nt">Epoch</span><span class="na"> 24000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">229660080.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">27.102589</span><span class="err"> </span><span class="nc">-238.44817</span><span class="err"> </span><span class="nc">309.35342</span><span class="err"> </span><span class="nc">2420.4185</span><span class="err"> </span><span class="nc">7770.5728</span><span class="err"> </span><span class="nc">19536.19</span> +<span class="nt">Epoch</span><span class="na"> 25000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">216972400.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">27.660324</span><span class="err"> </span><span class="nc">-245.69016</span><span class="err"> </span><span class="nc">318.10062</span><span class="err"> </span><span class="nc">2483.3608</span><span class="err"> </span><span class="nc">7957.354</span><span class="err"> </span><span class="nc">20027.707</span> <span class="nt">216972400.0</span><span class="na"> 27.660324 -245.69016 318.10062 2483.3608 7957.354 20027.707</span> </code></pre> </div> @@ -2108,7 +2108,7 @@ values using the X values. We then plot it to compare the actual data and predic </ul></li> <li>How about account suspensions without any prior notice? <ul> -<li><a rel="noopener" target="_blank" href="https://hn.algolia.com/?dateRange=all&page=0&prefix=true&query=account%20suspended&sort=byPopularity&type=story">Hacker News stories with “account suspended“</a></li> +<li><a rel="noopener" target="_blank" href="https://hn.algolia.com/?dateRange=all&page=0&prefix=true&query=account%20suspended&sort=byPopularity&type=story">Hacker News stories with “account suspended“</a></li> </ul></li> <li>Do you value security and privacy?</li> <li>Or, do you want a new hobby?</li> @@ -2883,20 +2883,20 @@ I created a sample JSON with only 3 examples (I know, very less, but works for a <p><img src="/assets/posts/swift-chatbot/drugs-json.png" alt="Screenshot of Sample Dataset" /></p> <div class="codehilite"> -<pre><span></span><code><span class="p">[</span><span class="w"></span> -<span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="nt">"tokens"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"Tell"</span><span class="p">,</span><span class="s2">"me"</span><span class="p">,</span><span class="s2">"about"</span><span class="p">,</span><span class="s2">"the"</span><span class="p">,</span><span class="s2">"drug"</span><span class="p">,</span><span class="s2">"Aspirin"</span><span class="p">,</span><span class="s2">"."</span><span class="p">],</span><span class="w"></span> -<span class="w"> </span><span class="nt">"labels"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"COMPOUND"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span><span class="p">},</span><span class="w"></span> -<span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="nt">"tokens"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"Please"</span><span class="p">,</span><span class="s2">"tell"</span><span class="p">,</span><span class="s2">"me"</span><span class="p">,</span><span class="s2">"information"</span><span class="p">,</span><span class="s2">"about"</span><span class="p">,</span><span class="s2">"the"</span><span class="p">,</span><span class="s2">"compound"</span><span class="p">,</span><span class="s2">"salicylic"</span><span class="p">,</span><span class="s2">"acid"</span><span class="p">,</span><span class="s2">"."</span><span class="p">],</span><span class="w"></span> -<span class="w"> </span><span class="nt">"labels"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"COMPOUND"</span><span class="p">,</span><span class="s2">"COMPOUND"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span><span class="p">},</span><span class="w"></span> -<span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="nt">"tokens"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"Information"</span><span class="p">,</span><span class="s2">"about"</span><span class="p">,</span><span class="s2">"the"</span><span class="p">,</span><span class="s2">"compound"</span><span class="p">,</span><span class="s2">"Ibuprofen"</span><span class="p">,</span><span class="s2">"please"</span><span class="p">,</span><span class="s2">"."</span><span class="p">],</span><span class="w"></span> -<span class="w"> </span><span class="nt">"labels"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"COMPOUND"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="p">]</span><span class="w"></span> +<pre><span></span><code><span class="p">[</span> +<span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nt">"tokens"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"Tell"</span><span class="p">,</span><span class="s2">"me"</span><span class="p">,</span><span class="s2">"about"</span><span class="p">,</span><span class="s2">"the"</span><span class="p">,</span><span class="s2">"drug"</span><span class="p">,</span><span class="s2">"Aspirin"</span><span class="p">,</span><span class="s2">"."</span><span class="p">],</span> +<span class="w"> </span><span class="nt">"labels"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"COMPOUND"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">]</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nt">"tokens"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"Please"</span><span class="p">,</span><span class="s2">"tell"</span><span class="p">,</span><span class="s2">"me"</span><span class="p">,</span><span class="s2">"information"</span><span class="p">,</span><span class="s2">"about"</span><span class="p">,</span><span class="s2">"the"</span><span class="p">,</span><span class="s2">"compound"</span><span class="p">,</span><span class="s2">"salicylic"</span><span class="p">,</span><span class="s2">"acid"</span><span class="p">,</span><span class="s2">"."</span><span class="p">],</span> +<span class="w"> </span><span class="nt">"labels"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"COMPOUND"</span><span class="p">,</span><span class="s2">"COMPOUND"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">]</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nt">"tokens"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"Information"</span><span class="p">,</span><span class="s2">"about"</span><span class="p">,</span><span class="s2">"the"</span><span class="p">,</span><span class="s2">"compound"</span><span class="p">,</span><span class="s2">"Ibuprofen"</span><span class="p">,</span><span class="s2">"please"</span><span class="p">,</span><span class="s2">"."</span><span class="p">],</span> +<span class="w"> </span><span class="nt">"labels"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"COMPOUND"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">]</span> +<span class="w"> </span><span class="p">}</span> +<span class="p">]</span> </code></pre> </div> @@ -3242,130 +3242,133 @@ logger.info("rdkit-{} installation finished!".format(rdkit.__version__)) <h2>Phase 1</h2> <div class="codehilite"> -<pre><span></span><code>joxxxn@jupyter-nxxh6xx8:~/lab2-bomblab-navanchauhan/bombbomb$ gdb -ex <span class="s1">'break phase_1'</span> -ex <span class="s1">'break explode_bomb'</span> -ex <span class="s1">'run'</span> ./bomb -GNU gdb <span class="o">(</span>Ubuntu <span class="m">12</span>.1-0ubuntu1~22.04<span class="o">)</span> <span class="m">12</span>.1 -Copyright <span class="o">(</span>C<span class="o">)</span> <span class="m">2022</span> Free Software Foundation, Inc. -License GPLv3+: GNU GPL version <span class="m">3</span> or later <http://gnu.org/licenses/gpl.html> -This is free software: you are free to change and redistribute it. -There is NO WARRANTY, to the extent permitted by law. -Type <span class="s2">"show copying"</span> and <span class="s2">"show warranty"</span> <span class="k">for</span> details. -This GDB was configured as <span class="s2">"x86_64-linux-gnu"</span>. -Type <span class="s2">"show configuration"</span> <span class="k">for</span> configuration details. -For bug reporting instructions, please see: +<pre><span></span><code>joxxxn@jupyter-nxxh6xx8:~/lab2-bomblab-navanchauhan/bombbomb$<span class="w"> </span>gdb<span class="w"> </span>-ex<span class="w"> </span><span class="s1">'break phase_1'</span><span class="w"> </span>-ex<span class="w"> </span><span class="s1">'break explode_bomb'</span><span class="w"> </span>-ex<span class="w"> </span><span class="s1">'run'</span><span class="w"> </span>./bomb<span class="w"> </span> +GNU<span class="w"> </span>gdb<span class="w"> </span><span class="o">(</span>Ubuntu<span class="w"> </span><span class="m">12</span>.1-0ubuntu1~22.04<span class="o">)</span><span class="w"> </span><span class="m">12</span>.1 +Copyright<span class="w"> </span><span class="o">(</span>C<span class="o">)</span><span class="w"> </span><span class="m">2022</span><span class="w"> </span>Free<span class="w"> </span>Software<span class="w"> </span>Foundation,<span class="w"> </span>Inc. +License<span class="w"> </span>GPLv3+:<span class="w"> </span>GNU<span class="w"> </span>GPL<span class="w"> </span>version<span class="w"> </span><span class="m">3</span><span class="w"> </span>or<span class="w"> </span>later<span class="w"> </span><http://gnu.org/licenses/gpl.html> +This<span class="w"> </span>is<span class="w"> </span>free<span class="w"> </span>software:<span class="w"> </span>you<span class="w"> </span>are<span class="w"> </span>free<span class="w"> </span>to<span class="w"> </span>change<span class="w"> </span>and<span class="w"> </span>redistribute<span class="w"> </span>it. +There<span class="w"> </span>is<span class="w"> </span>NO<span class="w"> </span>WARRANTY,<span class="w"> </span>to<span class="w"> </span>the<span class="w"> </span>extent<span class="w"> </span>permitted<span class="w"> </span>by<span class="w"> </span>law. +Type<span class="w"> </span><span class="s2">"show copying"</span><span class="w"> </span>and<span class="w"> </span><span class="s2">"show warranty"</span><span class="w"> </span><span class="k">for</span><span class="w"> </span>details. +This<span class="w"> </span>GDB<span class="w"> </span>was<span class="w"> </span>configured<span class="w"> </span>as<span class="w"> </span><span class="s2">"x86_64-linux-gnu"</span>. +Type<span class="w"> </span><span class="s2">"show configuration"</span><span class="w"> </span><span class="k">for</span><span class="w"> </span>configuration<span class="w"> </span>details. +For<span class="w"> </span>bug<span class="w"> </span>reporting<span class="w"> </span>instructions,<span class="w"> </span>please<span class="w"> </span>see: <https://www.gnu.org/software/gdb/bugs/>. -Find the GDB manual and other documentation resources online at: - <http://www.gnu.org/software/gdb/documentation/>. - -For help, <span class="nb">type</span> <span class="s2">"help"</span>. -Type <span class="s2">"apropos word"</span> to search <span class="k">for</span> commands related to <span class="s2">"word"</span>... -Reading symbols from ./bomb... -Breakpoint <span class="m">1</span> at 0x15c7 -Breakpoint <span class="m">2</span> at 0x1d4a -Starting program: /home/joxxxn/lab2-bomblab-navanchauhan/bombbomb/bomb -<span class="o">[</span>Thread debugging using libthread_db enabled<span class="o">]</span> -Using host libthread_db library <span class="s2">"/lib/x86_64-linux-gnu/libthread_db.so.1"</span>. -Welcome to my fiendish little bomb. You have <span class="m">6</span> phases with -which to blow yourself up. Have a nice day! -<span class="nb">test</span> string - -Breakpoint <span class="m">1</span>, 0x00005555555555c7 <span class="k">in</span> phase_1 <span class="o">()</span> -<span class="o">(</span>gdb<span class="o">)</span> dias phase_1 -Undefined command: <span class="s2">"dias"</span>. Try <span class="s2">"help"</span>. -<span class="o">(</span>gdb<span class="o">)</span> disas phase_1 -Dump of assembler code <span class="k">for</span> <span class="k">function</span> phase_1: -<span class="o">=</span>> 0x00005555555555c7 <+0>: endbr64 - 0x00005555555555cb <+4>: sub <span class="nv">$0</span>x8,%rsp - 0x00005555555555cf <+8>: lea 0x1b7a<span class="o">(</span>%rip<span class="o">)</span>,%rsi <span class="c1"># 0x555555557150</span> - 0x00005555555555d6 <+15>: call 0x555555555b31 <strings_not_equal> - 0x00005555555555db <+20>: <span class="nb">test</span> %eax,%eax - 0x00005555555555dd <+22>: jne 0x5555555555e4 <phase_1+29> - 0x00005555555555df <+24>: add <span class="nv">$0</span>x8,%rsp - 0x00005555555555e3 <+28>: ret - 0x00005555555555e4 <+29>: call 0x555555555d4a <explode_bomb> - 0x00005555555555e9 <+34>: jmp 0x5555555555df <phase_1+24> -End of assembler dump. -<span class="o">(</span>gdb<span class="o">)</span> print 0x555555557150 -<span class="nv">$1</span> <span class="o">=</span> <span class="m">93824992244048</span> -<span class="o">(</span>gdb<span class="o">)</span> x/1s 0x555555557150 -0x555555557150: <span class="s2">"Controlling complexity is the essence of computer programming."</span> -<span class="o">(</span>gdb<span class="o">)</span> +Find<span class="w"> </span>the<span class="w"> </span>GDB<span class="w"> </span>manual<span class="w"> </span>and<span class="w"> </span>other<span class="w"> </span>documentation<span class="w"> </span>resources<span class="w"> </span>online<span class="w"> </span>at: +<span class="w"> </span><http://www.gnu.org/software/gdb/documentation/>. + +For<span class="w"> </span>help,<span class="w"> </span><span class="nb">type</span><span class="w"> </span><span class="s2">"help"</span>. +Type<span class="w"> </span><span class="s2">"apropos word"</span><span class="w"> </span>to<span class="w"> </span>search<span class="w"> </span><span class="k">for</span><span class="w"> </span>commands<span class="w"> </span>related<span class="w"> </span>to<span class="w"> </span><span class="s2">"word"</span>... +Reading<span class="w"> </span>symbols<span class="w"> </span>from<span class="w"> </span>./bomb... +Breakpoint<span class="w"> </span><span class="m">1</span><span class="w"> </span>at<span class="w"> </span>0x15c7 +Breakpoint<span class="w"> </span><span class="m">2</span><span class="w"> </span>at<span class="w"> </span>0x1d4a +Starting<span class="w"> </span>program:<span class="w"> </span>/home/joxxxn/lab2-bomblab-navanchauhan/bombbomb/bomb<span class="w"> </span> +<span class="o">[</span>Thread<span class="w"> </span>debugging<span class="w"> </span>using<span class="w"> </span>libthread_db<span class="w"> </span>enabled<span class="o">]</span> +Using<span class="w"> </span>host<span class="w"> </span>libthread_db<span class="w"> </span>library<span class="w"> </span><span class="s2">"/lib/x86_64-linux-gnu/libthread_db.so.1"</span>. +Welcome<span class="w"> </span>to<span class="w"> </span>my<span class="w"> </span>fiendish<span class="w"> </span>little<span class="w"> </span>bomb.<span class="w"> </span>You<span class="w"> </span>have<span class="w"> </span><span class="m">6</span><span class="w"> </span>phases<span class="w"> </span>with +which<span class="w"> </span>to<span class="w"> </span>blow<span class="w"> </span>yourself<span class="w"> </span>up.<span class="w"> </span>Have<span class="w"> </span>a<span class="w"> </span>nice<span class="w"> </span>day! +<span class="nb">test</span><span class="w"> </span>string + +Breakpoint<span class="w"> </span><span class="m">1</span>,<span class="w"> </span>0x00005555555555c7<span class="w"> </span><span class="k">in</span><span class="w"> </span>phase_1<span class="w"> </span><span class="o">()</span> +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span>dias<span class="w"> </span>phase_1 +Undefined<span class="w"> </span>command:<span class="w"> </span><span class="s2">"dias"</span>.<span class="w"> </span>Try<span class="w"> </span><span class="s2">"help"</span>. +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span>disas<span class="w"> </span>phase_1 +Dump<span class="w"> </span>of<span class="w"> </span>assembler<span class="w"> </span>code<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="k">function</span><span class="w"> </span>phase_1: +<span class="o">=</span>><span class="w"> </span>0x00005555555555c7<span class="w"> </span><+0>:<span class="w"> </span>endbr64<span class="w"> </span> +<span class="w"> </span>0x00005555555555cb<span class="w"> </span><+4>:<span class="w"> </span>sub<span class="w"> </span><span class="nv">$0</span>x8,%rsp +<span class="w"> </span>0x00005555555555cf<span class="w"> </span><+8>:<span class="w"> </span>lea<span class="w"> </span>0x1b7a<span class="o">(</span>%rip<span class="o">)</span>,%rsi<span class="w"> </span><span class="c1"># 0x555555557150</span> +<span class="w"> </span>0x00005555555555d6<span class="w"> </span><+15>:<span class="w"> </span>call<span class="w"> </span>0x555555555b31<span class="w"> </span><strings_not_equal> +<span class="w"> </span>0x00005555555555db<span class="w"> </span><+20>:<span class="w"> </span><span class="nb">test</span><span class="w"> </span>%eax,%eax +<span class="w"> </span>0x00005555555555dd<span class="w"> </span><+22>:<span class="w"> </span>jne<span class="w"> </span>0x5555555555e4<span class="w"> </span><phase_1+29> +<span class="w"> </span>0x00005555555555df<span class="w"> </span><+24>:<span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x8,%rsp +<span class="w"> </span>0x00005555555555e3<span class="w"> </span><+28>:<span class="w"> </span>ret<span class="w"> </span> +<span class="w"> </span>0x00005555555555e4<span class="w"> </span><+29>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span>0x00005555555555e9<span class="w"> </span><+34>:<span class="w"> </span>jmp<span class="w"> </span>0x5555555555df<span class="w"> </span><phase_1+24> +End<span class="w"> </span>of<span class="w"> </span>assembler<span class="w"> </span>dump. +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span>print<span class="w"> </span>0x555555557150 +<span class="nv">$1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="m">93824992244048</span> +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span>x/1s<span class="w"> </span>0x555555557150 +0x555555557150:<span class="w"> </span><span class="s2">"Controlling complexity is the essence of computer programming."</span> +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span> </code></pre> </div> <h2>Phase 2</h2> <div class="codehilite"> -<pre><span></span><code>Phase <span class="m">1</span> defused. How about the next one? -<span class="m">1</span> <span class="m">2</span> <span class="m">3</span> <span class="m">4</span> <span class="m">5</span> <span class="m">6</span> - -Breakpoint <span class="m">1</span>, 0x00005555555555eb <span class="k">in</span> phase_2 <span class="o">()</span> -<span class="o">(</span>gdb<span class="o">)</span> disas -Dump of assembler code <span class="k">for</span> <span class="k">function</span> phase_2: -<span class="o">=</span>> 0x00005555555555eb <+0>: endbr64 - 0x00005555555555ef <+4>: push %rbp - 0x00005555555555f0 <+5>: push %rbx - 0x00005555555555f1 <+6>: sub <span class="nv">$0</span>x28,%rsp - 0x00005555555555f5 <+10>: mov %rsp,%rsi - 0x00005555555555f8 <+13>: call 0x555555555d97 <read_six_numbers> - 0x00005555555555fd <+18>: cmpl <span class="nv">$0</span>x0,<span class="o">(</span>%rsp<span class="o">)</span> - 0x0000555555555601 <+22>: js 0x55555555560d <phase_2+34> - 0x0000555555555603 <+24>: mov %rsp,%rbp - 0x0000555555555606 <+27>: mov <span class="nv">$0</span>x1,%ebx - 0x000055555555560b <+32>: jmp 0x555555555620 <phase_2+53> - 0x000055555555560d <+34>: call 0x555555555d4a <explode_bomb> - 0x0000555555555612 <+39>: jmp 0x555555555603 <phase_2+24> - 0x0000555555555614 <+41>: add <span class="nv">$0</span>x1,%ebx - 0x0000555555555617 <+44>: add <span class="nv">$0</span>x4,%rbp - 0x000055555555561b <+48>: cmp <span class="nv">$0</span>x6,%ebx - 0x000055555555561e <+51>: je 0x555555555631 <phase_2+70> - 0x0000555555555620 <+53>: mov %ebx,%eax - 0x0000555555555622 <+55>: add 0x0<span class="o">(</span>%rbp<span class="o">)</span>,%eax - 0x0000555555555625 <+58>: cmp %eax,0x4<span class="o">(</span>%rbp<span class="o">)</span> - 0x0000555555555628 <+61>: je 0x555555555614 <phase_2+41> - 0x000055555555562a <+63>: call 0x555555555d4a <explode_bomb> - 0x000055555555562f <+68>: jmp 0x555555555614 <phase_2+41> - 0x0000555555555631 <+70>: add <span class="nv">$0</span>x28,%rsp - 0x0000555555555635 <+74>: pop %rbx - 0x0000555555555636 <+75>: pop %rbp - 0x0000555555555637 <+76>: ret -End of assembler dump. -<span class="o">(</span>gdb<span class="o">)</span> -</code></pre> -</div> - -<div class="codehilite"> -<pre><span></span><code> 0x00005555555555fd <+18>: cmpl <span class="nv">$0</span>x0,<span class="o">(</span>%rsp<span class="o">)</span> - 0x0000555555555601 <+22>: js 0x55555555560d <phase_2+34> +<pre><span></span><code>Phase<span class="w"> </span><span class="m">1</span><span class="w"> </span>defused.<span class="w"> </span>How<span class="w"> </span>about<span class="w"> </span>the<span class="w"> </span>next<span class="w"> </span>one? +<span class="m">1</span><span class="w"> </span><span class="m">2</span><span class="w"> </span><span class="m">3</span><span class="w"> </span><span class="m">4</span><span class="w"> </span><span class="m">5</span><span class="w"> </span><span class="m">6</span> + +Breakpoint<span class="w"> </span><span class="m">1</span>,<span class="w"> </span>0x00005555555555eb<span class="w"> </span><span class="k">in</span><span class="w"> </span>phase_2<span class="w"> </span><span class="o">()</span> +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span>disas +Dump<span class="w"> </span>of<span class="w"> </span>assembler<span class="w"> </span>code<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="k">function</span><span class="w"> </span>phase_2: +<span class="o">=</span>><span class="w"> </span>0x00005555555555eb<span class="w"> </span><+0>:<span class="w"> </span>endbr64<span class="w"> </span> +<span class="w"> </span>0x00005555555555ef<span class="w"> </span><+4>:<span class="w"> </span>push<span class="w"> </span>%rbp +<span class="w"> </span>0x00005555555555f0<span class="w"> </span><+5>:<span class="w"> </span>push<span class="w"> </span>%rbx +<span class="w"> </span>0x00005555555555f1<span class="w"> </span><+6>:<span class="w"> </span>sub<span class="w"> </span><span class="nv">$0</span>x28,%rsp +<span class="w"> </span>0x00005555555555f5<span class="w"> </span><+10>:<span class="w"> </span>mov<span class="w"> </span>%rsp,%rsi +<span class="w"> </span>0x00005555555555f8<span class="w"> </span><+13>:<span class="w"> </span>call<span class="w"> </span>0x555555555d97<span class="w"> </span><read_six_numbers> +<span class="w"> </span>0x00005555555555fd<span class="w"> </span><+18>:<span class="w"> </span>cmpl<span class="w"> </span><span class="nv">$0</span>x0,<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>0x0000555555555601<span class="w"> </span><+22>:<span class="w"> </span>js<span class="w"> </span>0x55555555560d<span class="w"> </span><phase_2+34> +<span class="w"> </span>0x0000555555555603<span class="w"> </span><+24>:<span class="w"> </span>mov<span class="w"> </span>%rsp,%rbp +<span class="w"> </span>0x0000555555555606<span class="w"> </span><+27>:<span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x1,%ebx +<span class="w"> </span>0x000055555555560b<span class="w"> </span><+32>:<span class="w"> </span>jmp<span class="w"> </span>0x555555555620<span class="w"> </span><phase_2+53> +<span class="w"> </span>0x000055555555560d<span class="w"> </span><+34>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span>0x0000555555555612<span class="w"> </span><+39>:<span class="w"> </span>jmp<span class="w"> </span>0x555555555603<span class="w"> </span><phase_2+24> +<span class="w"> </span>0x0000555555555614<span class="w"> </span><+41>:<span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x1,%ebx +<span class="w"> </span>0x0000555555555617<span class="w"> </span><+44>:<span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x4,%rbp +<span class="w"> </span>0x000055555555561b<span class="w"> </span><+48>:<span class="w"> </span>cmp<span class="w"> </span><span class="nv">$0</span>x6,%ebx +<span class="w"> </span>0x000055555555561e<span class="w"> </span><+51>:<span class="w"> </span>je<span class="w"> </span>0x555555555631<span class="w"> </span><phase_2+70> +<span class="w"> </span>0x0000555555555620<span class="w"> </span><+53>:<span class="w"> </span>mov<span class="w"> </span>%ebx,%eax +<span class="w"> </span>0x0000555555555622<span class="w"> </span><+55>:<span class="w"> </span>add<span class="w"> </span>0x0<span class="o">(</span>%rbp<span class="o">)</span>,%eax +<span class="w"> </span>0x0000555555555625<span class="w"> </span><+58>:<span class="w"> </span>cmp<span class="w"> </span>%eax,0x4<span class="o">(</span>%rbp<span class="o">)</span> +<span class="w"> </span>0x0000555555555628<span class="w"> </span><+61>:<span class="w"> </span>je<span class="w"> </span>0x555555555614<span class="w"> </span><phase_2+41> +<span class="w"> </span>0x000055555555562a<span class="w"> </span><+63>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span>0x000055555555562f<span class="w"> </span><+68>:<span class="w"> </span>jmp<span class="w"> </span>0x555555555614<span class="w"> </span><phase_2+41> +<span class="w"> </span>0x0000555555555631<span class="w"> </span><+70>:<span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x28,%rsp +<span class="w"> </span>0x0000555555555635<span class="w"> </span><+74>:<span class="w"> </span>pop<span class="w"> </span>%rbx +<span class="w"> </span>0x0000555555555636<span class="w"> </span><+75>:<span class="w"> </span>pop<span class="w"> </span>%rbp +<span class="w"> </span>0x0000555555555637<span class="w"> </span><+76>:<span class="w"> </span>ret<span class="w"> </span> +End<span class="w"> </span>of<span class="w"> </span>assembler<span class="w"> </span>dump. +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span> +</code></pre> +</div> + +<div class="codehilite"> +<pre><span></span><code><span class="w"> </span>0x00005555555555fd<span class="w"> </span><+18>:<span class="w"> </span>cmpl<span class="w"> </span><span class="nv">$0</span>x0,<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>0x0000555555555601<span class="w"> </span><+22>:<span class="w"> </span>js<span class="w"> </span>0x55555555560d<span class="w"> </span><phase_2+34> ... - 0x000055555555560d <+34>: call 0x555555555d4a <explode_bomb> +<span class="w"> </span>0x000055555555560d<span class="w"> </span><+34>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> </code></pre> </div> -<p>The program first compares if the first number is not 0. If the number is not 0, then the <code>cmpl</code> instruction returns a negative value. The <code>js</code> instruction stands for jump if sign -> causing a jump to the specified address if the sign bit is set. This would result in the explode_bomb function being called. - <div class="codehilite"> - <pre><span></span><code>0x0000555555555603 <+24>: mov %rsp,%rbp - 0x0000555555555606 <+27>: mov <span class="nv">$0</span>x1,%ebx - </code></pre> - </div></p> +<p>The program first compares if the first number is not 0. If the number is not 0, then the <code>cmpl</code> instruction returns a negative value. The <code>js</code> instruction stands for jump if sign -> causing a jump to the specified address if the sign bit is set. This would result in the explode_bomb function being called.</p> + +<div class="codehilite"> +<pre><span></span><code><span class="w"> </span>0x0000555555555603<span class="w"> </span><+24>:<span class="w"> </span>mov<span class="w"> </span>%rsp,%rbp +<span class="w"> </span>0x0000555555555606<span class="w"> </span><+27>:<span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x1,%ebx +</code></pre> +</div> <p><code>%rsp</code> in x86-64 asm, is the stack pointer i.e. it points to the top of the current stack frame. Since the program just read six numbers, the top of the stack (<code>%rsp</code>) contains the address of the first number.</p> <p>By executing <code>mov %rsp,%rbp</code> we are setting the base pointer (<code>%rbp</code>) to point to this address.</p> -<p>Now, for the second instruction <code>mov $0x1,%ebx</code>, we are initalising the <code>%ebx</code> register with the value 1. Based on the assembly code, you can see that this is being used as a counter/index for the loop. - <div class="codehilite"> - <pre><span></span><code>0x000055555555560b <+32>: jmp 0x555555555620 <phase_2+53> - </code></pre> - </div></p> - -<p>The program now jumps to <phase_2+53> - <div class="codehilite"> - <pre><span></span><code>0x0000555555555620 <+53>: mov %ebx,%eax - 0x0000555555555622 <+55>: add 0x0<span class="o">(</span>%rbp<span class="o">)</span>,%eax - 0x0000555555555625 <+58>: cmp %eax,0x4<span class="o">(</span>%rbp<span class="o">)</span> - 0x0000555555555628 <+61>: je 0x555555555614 <phase_2+41> - </code></pre> - </div></p> +<p>Now, for the second instruction <code>mov $0x1,%ebx</code>, we are initalising the <code>%ebx</code> register with the value 1. Based on the assembly code, you can see that this is being used as a counter/index for the loop.</p> + +<div class="codehilite"> +<pre><span></span><code><span class="w"> </span>0x000055555555560b<span class="w"> </span><+32>:<span class="w"> </span>jmp<span class="w"> </span>0x555555555620<span class="w"> </span><phase_2+53> +</code></pre> +</div> + +<p>The program now jumps to <phase_2+53></p> + +<div class="codehilite"> +<pre><span></span><code><span class="w"> </span>0x0000555555555620<span class="w"> </span><+53>:<span class="w"> </span>mov<span class="w"> </span>%ebx,%eax +<span class="w"> </span>0x0000555555555622<span class="w"> </span><+55>:<span class="w"> </span>add<span class="w"> </span>0x0<span class="o">(</span>%rbp<span class="o">)</span>,%eax +<span class="w"> </span>0x0000555555555625<span class="w"> </span><+58>:<span class="w"> </span>cmp<span class="w"> </span>%eax,0x4<span class="o">(</span>%rbp<span class="o">)</span> +<span class="w"> </span>0x0000555555555628<span class="w"> </span><+61>:<span class="w"> </span>je<span class="w"> </span>0x555555555614<span class="w"> </span><phase_2+41> +</code></pre> +</div> <p>Here, the value from <code>%ebx</code> is copied to the <code>%eax</code> register. For this iteration, the value should be 1.</p> @@ -3373,18 +3376,19 @@ End of assembler dump. <p><code>cmp %eax,0x4(%rbp)</code> - The instruction compares the value in %eax to the value at the memory address <code>%rbp + 4</code>. Since Integers in this context are stored using a word of memory of 4 bytes, this indicates it checks against the second number in the sequence.</p> -<p><code>je 0x555555555614 <phase_2+41></code> - The program will jump to <code>phase_2+41</code> if the previous <code>cmp</code> instruction determined the values as equal. - <div class="codehilite"> - <pre><span></span><code>0x0000555555555614 <+41>: add <span class="nv">$0</span>x1,%ebx - 0x0000555555555617 <+44>: add <span class="nv">$0</span>x4,%rbp - 0x000055555555561b <+48>: cmp <span class="nv">$0</span>x6,%ebx - 0x000055555555561e <+51>: je 0x555555555631 <phase<em>2+70> - 0x0000555555555620 <+53>: mov %ebx,%eax - 0x0000555555555622 <+55>: add 0x0<span class="o">(</span>%rbp<span class="o">)</span>,%eax - 0x0000555555555625 <+58>: cmp %eax,0x4<span class="o">(</span>%rbp<span class="o">)</span> - 0x0000555555555628 <+61>: je 0x555555555614 <phase</em>2+41> - </code></pre> - </div></p> +<p><code>je 0x555555555614 <phase_2+41></code> - The program will jump to <code>phase_2+41</code> if the previous <code>cmp</code> instruction determined the values as equal. </p> + +<div class="codehilite"> +<pre><span></span><code><span class="w"> </span>0x0000555555555614<span class="w"> </span><+41>:<span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x1,%ebx +<span class="w"> </span>0x0000555555555617<span class="w"> </span><+44>:<span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x4,%rbp +<span class="w"> </span>0x000055555555561b<span class="w"> </span><+48>:<span class="w"> </span>cmp<span class="w"> </span><span class="nv">$0</span>x6,%ebx +<span class="w"> </span>0x000055555555561e<span class="w"> </span><+51>:<span class="w"> </span>je<span class="w"> </span>0x555555555631<span class="w"> </span><phase_2+70> +<span class="w"> </span>0x0000555555555620<span class="w"> </span><+53>:<span class="w"> </span>mov<span class="w"> </span>%ebx,%eax +<span class="w"> </span>0x0000555555555622<span class="w"> </span><+55>:<span class="w"> </span>add<span class="w"> </span>0x0<span class="o">(</span>%rbp<span class="o">)</span>,%eax +<span class="w"> </span>0x0000555555555625<span class="w"> </span><+58>:<span class="w"> </span>cmp<span class="w"> </span>%eax,0x4<span class="o">(</span>%rbp<span class="o">)</span> +<span class="w"> </span>0x0000555555555628<span class="w"> </span><+61>:<span class="w"> </span>je<span class="w"> </span>0x555555555614<span class="w"> </span><phase_2+41> +</code></pre> +</div> <p>Here, we can see that the program increments <code>%ebx</code> by 1, adds a 4 byte offset to <code>%rbp</code> (the number we will be matching now), and checks if <code>%ebx</code> is equal to 6. If it is, it breaks the loop and jumps to <code><phase_2+70></code> succesfully finishing this stage.</p> @@ -3401,13 +3405,13 @@ End of assembler dump. <div class="codehilite"> <pre><span></span><code>... -Phase <span class="m">1</span> defused. How about the next one? -<span class="m">0</span> <span class="m">1</span> <span class="m">3</span> <span class="m">6</span> <span class="m">10</span> <span class="m">15</span> +Phase<span class="w"> </span><span class="m">1</span><span class="w"> </span>defused.<span class="w"> </span>How<span class="w"> </span>about<span class="w"> </span>the<span class="w"> </span>next<span class="w"> </span>one? +<span class="m">0</span><span class="w"> </span><span class="m">1</span><span class="w"> </span><span class="m">3</span><span class="w"> </span><span class="m">6</span><span class="w"> </span><span class="m">10</span><span class="w"> </span><span class="m">15</span> -Breakpoint <span class="m">1</span>, 0x00005555555555eb <span class="k">in</span> phase_2 <span class="o">()</span> -<span class="o">(</span>gdb<span class="o">)</span> <span class="k">continue</span> +Breakpoint<span class="w"> </span><span class="m">1</span>,<span class="w"> </span>0x00005555555555eb<span class="w"> </span><span class="k">in</span><span class="w"> </span>phase_2<span class="w"> </span><span class="o">()</span> +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span><span class="k">continue</span> Continuing. -That<span class="err">'</span>s number <span class="m">2</span>. Keep going! +That<span class="err">'</span>s<span class="w"> </span>number<span class="w"> </span><span class="m">2</span>.<span class="w"> </span>Keep<span class="w"> </span>going! </code></pre> </div> @@ -3416,96 +3420,96 @@ That<span class="err">'</span>s number <span class="m">2</span>. Keep going <p>Let us look at the disassembled code first</p> <div class="codehilite"> -<pre><span></span><code><span class="m">0000000000001638</span> <phase_3>: - <span class="m">1638</span>: f3 0f 1e fa endbr64 - 163c: <span class="m">48</span> <span class="m">83</span> ec <span class="m">18</span> sub <span class="nv">$0</span>x18,%rsp - <span class="m">1640</span>: <span class="m">48</span> 8d 4c <span class="m">24</span> <span class="m">07</span> lea 0x7<span class="o">(</span>%rsp<span class="o">)</span>,%rcx - <span class="m">1645</span>: <span class="m">48</span> 8d <span class="m">54</span> <span class="m">24</span> 0c lea 0xc<span class="o">(</span>%rsp<span class="o">)</span>,%rdx - 164a: 4c 8d <span class="m">44</span> <span class="m">24</span> <span class="m">08</span> lea 0x8<span class="o">(</span>%rsp<span class="o">)</span>,%r8 - 164f: <span class="m">48</span> 8d <span class="m">35</span> <span class="m">60</span> 1b <span class="m">00</span> <span class="m">00</span> lea 0x1b60<span class="o">(</span>%rip<span class="o">)</span>,%rsi <span class="c1"># 31b6 <_IO_stdin_used+0x1b6></span> - <span class="m">1656</span>: b8 <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> mov <span class="nv">$0</span>x0,%eax - 165b: e8 <span class="m">80</span> <span class="nb">fc</span> ff ff call 12e0 <__isoc99_sscanf@plt> - <span class="m">1660</span>: <span class="m">83</span> f8 <span class="m">02</span> cmp <span class="nv">$0</span>x2,%eax - <span class="m">1663</span>: 7e <span class="m">20</span> jle <span class="m">1685</span> <phase_3+0x4d> - <span class="m">1665</span>: <span class="m">83</span> 7c <span class="m">24</span> 0c <span class="m">07</span> cmpl <span class="nv">$0</span>x7,0xc<span class="o">(</span>%rsp<span class="o">)</span> - 166a: 0f <span class="m">87</span> 0d <span class="m">01</span> <span class="m">00</span> <span class="m">00</span> ja 177d <phase_3+0x145> - <span class="m">1670</span>: 8b <span class="m">44</span> <span class="m">24</span> 0c mov 0xc<span class="o">(</span>%rsp<span class="o">)</span>,%eax - <span class="m">1674</span>: <span class="m">48</span> 8d <span class="m">15</span> <span class="m">55</span> 1b <span class="m">00</span> <span class="m">00</span> lea 0x1b55<span class="o">(</span>%rip<span class="o">)</span>,%rdx <span class="c1"># 31d0 <_IO_stdin_used+0x1d0></span> - 167b: <span class="m">48</span> <span class="m">63</span> <span class="m">04</span> <span class="m">82</span> movslq <span class="o">(</span>%rdx,%rax,4<span class="o">)</span>,%rax - 167f: <span class="m">48</span> <span class="m">01</span> d0 add %rdx,%rax - <span class="m">1682</span>: 3e ff e0 notrack jmp *%rax - <span class="m">1685</span>: e8 c0 <span class="m">06</span> <span class="m">00</span> <span class="m">00</span> call 1d4a <explode_bomb> - 168a: eb d9 jmp <span class="m">1665</span> <phase_3+0x2d> - 168c: b8 <span class="m">63</span> <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> mov <span class="nv">$0</span>x63,%eax - <span class="m">1691</span>: <span class="m">81</span> 7c <span class="m">24</span> <span class="m">08</span> 3d <span class="m">02</span> <span class="m">00</span> cmpl <span class="nv">$0</span>x23d,0x8<span class="o">(</span>%rsp<span class="o">)</span> - <span class="m">1698</span>: <span class="m">00</span> - <span class="m">1699</span>: 0f <span class="m">84</span> e8 <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> je <span class="m">1787</span> <phase_3+0x14f> - 169f: e8 a6 <span class="m">06</span> <span class="m">00</span> <span class="m">00</span> call 1d4a <explode_bomb> - 16a4: b8 <span class="m">63</span> <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> mov <span class="nv">$0</span>x63,%eax - 16a9: e9 d9 <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> jmp <span class="m">1787</span> <phase_3+0x14f> - 16ae: b8 <span class="m">61</span> <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> mov <span class="nv">$0</span>x61,%eax - 16b3: <span class="m">81</span> 7c <span class="m">24</span> <span class="m">08</span> <span class="m">27</span> <span class="m">01</span> <span class="m">00</span> cmpl <span class="nv">$0</span>x127,0x8<span class="o">(</span>%rsp<span class="o">)</span> - 16ba: <span class="m">00</span> - 16bb: 0f <span class="m">84</span> c6 <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> je <span class="m">1787</span> <phase_3+0x14f> - 16c1: e8 <span class="m">84</span> <span class="m">06</span> <span class="m">00</span> <span class="m">00</span> call 1d4a <explode_bomb> - 16c6: b8 <span class="m">61</span> <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> mov <span class="nv">$0</span>x61,%eax - 16cb: e9 b7 <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> jmp <span class="m">1787</span> <phase_3+0x14f> - 16d0: b8 <span class="m">78</span> <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> mov <span class="nv">$0</span>x78,%eax - 16d5: <span class="m">81</span> 7c <span class="m">24</span> <span class="m">08</span> e7 <span class="m">02</span> <span class="m">00</span> cmpl <span class="nv">$0</span>x2e7,0x8<span class="o">(</span>%rsp<span class="o">)</span> - 16dc: <span class="m">00</span> - 16dd: 0f <span class="m">84</span> a4 <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> je <span class="m">1787</span> <phase_3+0x14f> - 16e3: e8 <span class="m">62</span> <span class="m">06</span> <span class="m">00</span> <span class="m">00</span> call 1d4a <explode_bomb> - 16e8: b8 <span class="m">78</span> <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> mov <span class="nv">$0</span>x78,%eax - 16ed: e9 <span class="m">95</span> <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> jmp <span class="m">1787</span> <phase_3+0x14f> - 16f2: b8 <span class="m">64</span> <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> mov <span class="nv">$0</span>x64,%eax - 16f7: <span class="m">81</span> 7c <span class="m">24</span> <span class="m">08</span> <span class="m">80</span> <span class="m">02</span> <span class="m">00</span> cmpl <span class="nv">$0</span>x280,0x8<span class="o">(</span>%rsp<span class="o">)</span> - 16fe: <span class="m">00</span> - 16ff: 0f <span class="m">84</span> <span class="m">82</span> <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> je <span class="m">1787</span> <phase_3+0x14f> - <span class="m">1705</span>: e8 <span class="m">40</span> <span class="m">06</span> <span class="m">00</span> <span class="m">00</span> call 1d4a <explode_bomb> - 170a: b8 <span class="m">64</span> <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> mov <span class="nv">$0</span>x64,%eax - 170f: eb <span class="m">76</span> jmp <span class="m">1787</span> <phase_3+0x14f> - <span class="m">1711</span>: b8 6d <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> mov <span class="nv">$0</span>x6d,%eax - <span class="m">1716</span>: <span class="m">81</span> 7c <span class="m">24</span> <span class="m">08</span> ff <span class="m">02</span> <span class="m">00</span> cmpl <span class="nv">$0</span>x2ff,0x8<span class="o">(</span>%rsp<span class="o">)</span> - 171d: <span class="m">00</span> - 171e: <span class="m">74</span> <span class="m">67</span> je <span class="m">1787</span> <phase_3+0x14f> - <span class="m">1720</span>: e8 <span class="m">25</span> <span class="m">06</span> <span class="m">00</span> <span class="m">00</span> call 1d4a <explode_bomb> - <span class="m">1725</span>: b8 6d <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> mov <span class="nv">$0</span>x6d,%eax - 172a: eb 5b jmp <span class="m">1787</span> <phase_3+0x14f> - 172c: b8 <span class="m">71</span> <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> mov <span class="nv">$0</span>x71,%eax - <span class="m">1731</span>: <span class="m">81</span> 7c <span class="m">24</span> <span class="m">08</span> <span class="m">75</span> <span class="m">03</span> <span class="m">00</span> cmpl <span class="nv">$0</span>x375,0x8<span class="o">(</span>%rsp<span class="o">)</span> - <span class="m">1738</span>: <span class="m">00</span> - <span class="m">1739</span>: <span class="m">74</span> 4c je <span class="m">1787</span> <phase_3+0x14f> - 173b: e8 0a <span class="m">06</span> <span class="m">00</span> <span class="m">00</span> call 1d4a <explode_bomb> - <span class="m">1740</span>: b8 <span class="m">71</span> <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> mov <span class="nv">$0</span>x71,%eax - <span class="m">1745</span>: eb <span class="m">40</span> jmp <span class="m">1787</span> <phase_3+0x14f> - <span class="m">1747</span>: b8 <span class="m">79</span> <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> mov <span class="nv">$0</span>x79,%eax - 174c: <span class="m">81</span> 7c <span class="m">24</span> <span class="m">08</span> <span class="m">94</span> <span class="m">02</span> <span class="m">00</span> cmpl <span class="nv">$0</span>x294,0x8<span class="o">(</span>%rsp<span class="o">)</span> - <span class="m">1753</span>: <span class="m">00</span> - <span class="m">1754</span>: <span class="m">74</span> <span class="m">31</span> je <span class="m">1787</span> <phase_3+0x14f> - <span class="m">1756</span>: e8 ef <span class="m">05</span> <span class="m">00</span> <span class="m">00</span> call 1d4a <explode_bomb> - 175b: b8 <span class="m">79</span> <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> mov <span class="nv">$0</span>x79,%eax - <span class="m">1760</span>: eb <span class="m">25</span> jmp <span class="m">1787</span> <phase_3+0x14f> - <span class="m">1762</span>: b8 <span class="m">79</span> <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> mov <span class="nv">$0</span>x79,%eax - <span class="m">1767</span>: <span class="m">81</span> 7c <span class="m">24</span> <span class="m">08</span> <span class="m">88</span> <span class="m">02</span> <span class="m">00</span> cmpl <span class="nv">$0</span>x288,0x8<span class="o">(</span>%rsp<span class="o">)</span> - 176e: <span class="m">00</span> - 176f: <span class="m">74</span> <span class="m">16</span> je <span class="m">1787</span> <phase_3+0x14f> - <span class="m">1771</span>: e8 d4 <span class="m">05</span> <span class="m">00</span> <span class="m">00</span> call 1d4a <explode_bomb> - <span class="m">1776</span>: b8 <span class="m">79</span> <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> mov <span class="nv">$0</span>x79,%eax - 177b: eb 0a jmp <span class="m">1787</span> <phase_3+0x14f> - 177d: e8 c8 <span class="m">05</span> <span class="m">00</span> <span class="m">00</span> call 1d4a <explode_bomb> - <span class="m">1782</span>: b8 <span class="m">68</span> <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> mov <span class="nv">$0</span>x68,%eax - <span class="m">1787</span>: <span class="m">38</span> <span class="m">44</span> <span class="m">24</span> <span class="m">07</span> cmp %al,0x7<span class="o">(</span>%rsp<span class="o">)</span> - 178b: <span class="m">75</span> <span class="m">05</span> jne <span class="m">1792</span> <phase_3+0x15a> - 178d: <span class="m">48</span> <span class="m">83</span> c4 <span class="m">18</span> add <span class="nv">$0</span>x18,%rsp - <span class="m">1791</span>: c3 ret - <span class="m">1792</span>: e8 b3 <span class="m">05</span> <span class="m">00</span> <span class="m">00</span> call 1d4a <explode_bomb> - <span class="m">1797</span>: eb f4 jmp 178d <phase_3+0x155> +<pre><span></span><code><span class="m">0000000000001638</span><span class="w"> </span><phase_3>: +<span class="w"> </span><span class="m">1638</span>:<span class="w"> </span>f3<span class="w"> </span>0f<span class="w"> </span>1e<span class="w"> </span>fa<span class="w"> </span>endbr64<span class="w"> </span> +<span class="w"> </span>163c:<span class="w"> </span><span class="m">48</span><span class="w"> </span><span class="m">83</span><span class="w"> </span>ec<span class="w"> </span><span class="m">18</span><span class="w"> </span>sub<span class="w"> </span><span class="nv">$0</span>x18,%rsp +<span class="w"> </span><span class="m">1640</span>:<span class="w"> </span><span class="m">48</span><span class="w"> </span>8d<span class="w"> </span>4c<span class="w"> </span><span class="m">24</span><span class="w"> </span><span class="m">07</span><span class="w"> </span>lea<span class="w"> </span>0x7<span class="o">(</span>%rsp<span class="o">)</span>,%rcx +<span class="w"> </span><span class="m">1645</span>:<span class="w"> </span><span class="m">48</span><span class="w"> </span>8d<span class="w"> </span><span class="m">54</span><span class="w"> </span><span class="m">24</span><span class="w"> </span>0c<span class="w"> </span>lea<span class="w"> </span>0xc<span class="o">(</span>%rsp<span class="o">)</span>,%rdx +<span class="w"> </span>164a:<span class="w"> </span>4c<span class="w"> </span>8d<span class="w"> </span><span class="m">44</span><span class="w"> </span><span class="m">24</span><span class="w"> </span><span class="m">08</span><span class="w"> </span>lea<span class="w"> </span>0x8<span class="o">(</span>%rsp<span class="o">)</span>,%r8 +<span class="w"> </span>164f:<span class="w"> </span><span class="m">48</span><span class="w"> </span>8d<span class="w"> </span><span class="m">35</span><span class="w"> </span><span class="m">60</span><span class="w"> </span>1b<span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>lea<span class="w"> </span>0x1b60<span class="o">(</span>%rip<span class="o">)</span>,%rsi<span class="w"> </span><span class="c1"># 31b6 <_IO_stdin_used+0x1b6></span> +<span class="w"> </span><span class="m">1656</span>:<span class="w"> </span>b8<span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x0,%eax +<span class="w"> </span>165b:<span class="w"> </span>e8<span class="w"> </span><span class="m">80</span><span class="w"> </span><span class="nb">fc</span><span class="w"> </span>ff<span class="w"> </span>ff<span class="w"> </span>call<span class="w"> </span>12e0<span class="w"> </span><__isoc99_sscanf@plt> +<span class="w"> </span><span class="m">1660</span>:<span class="w"> </span><span class="m">83</span><span class="w"> </span>f8<span class="w"> </span><span class="m">02</span><span class="w"> </span>cmp<span class="w"> </span><span class="nv">$0</span>x2,%eax +<span class="w"> </span><span class="m">1663</span>:<span class="w"> </span>7e<span class="w"> </span><span class="m">20</span><span class="w"> </span>jle<span class="w"> </span><span class="m">1685</span><span class="w"> </span><phase_3+0x4d> +<span class="w"> </span><span class="m">1665</span>:<span class="w"> </span><span class="m">83</span><span class="w"> </span>7c<span class="w"> </span><span class="m">24</span><span class="w"> </span>0c<span class="w"> </span><span class="m">07</span><span class="w"> </span>cmpl<span class="w"> </span><span class="nv">$0</span>x7,0xc<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>166a:<span class="w"> </span>0f<span class="w"> </span><span class="m">87</span><span class="w"> </span>0d<span class="w"> </span><span class="m">01</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>ja<span class="w"> </span>177d<span class="w"> </span><phase_3+0x145> +<span class="w"> </span><span class="m">1670</span>:<span class="w"> </span>8b<span class="w"> </span><span class="m">44</span><span class="w"> </span><span class="m">24</span><span class="w"> </span>0c<span class="w"> </span>mov<span class="w"> </span>0xc<span class="o">(</span>%rsp<span class="o">)</span>,%eax +<span class="w"> </span><span class="m">1674</span>:<span class="w"> </span><span class="m">48</span><span class="w"> </span>8d<span class="w"> </span><span class="m">15</span><span class="w"> </span><span class="m">55</span><span class="w"> </span>1b<span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>lea<span class="w"> </span>0x1b55<span class="o">(</span>%rip<span class="o">)</span>,%rdx<span class="w"> </span><span class="c1"># 31d0 <_IO_stdin_used+0x1d0></span> +<span class="w"> </span>167b:<span class="w"> </span><span class="m">48</span><span class="w"> </span><span class="m">63</span><span class="w"> </span><span class="m">04</span><span class="w"> </span><span class="m">82</span><span class="w"> </span>movslq<span class="w"> </span><span class="o">(</span>%rdx,%rax,4<span class="o">)</span>,%rax +<span class="w"> </span>167f:<span class="w"> </span><span class="m">48</span><span class="w"> </span><span class="m">01</span><span class="w"> </span>d0<span class="w"> </span>add<span class="w"> </span>%rdx,%rax +<span class="w"> </span><span class="m">1682</span>:<span class="w"> </span>3e<span class="w"> </span>ff<span class="w"> </span>e0<span class="w"> </span>notrack<span class="w"> </span>jmp<span class="w"> </span>*%rax +<span class="w"> </span><span class="m">1685</span>:<span class="w"> </span>e8<span class="w"> </span>c0<span class="w"> </span><span class="m">06</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>call<span class="w"> </span>1d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span>168a:<span class="w"> </span>eb<span class="w"> </span>d9<span class="w"> </span>jmp<span class="w"> </span><span class="m">1665</span><span class="w"> </span><phase_3+0x2d> +<span class="w"> </span>168c:<span class="w"> </span>b8<span class="w"> </span><span class="m">63</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x63,%eax +<span class="w"> </span><span class="m">1691</span>:<span class="w"> </span><span class="m">81</span><span class="w"> </span>7c<span class="w"> </span><span class="m">24</span><span class="w"> </span><span class="m">08</span><span class="w"> </span>3d<span class="w"> </span><span class="m">02</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>cmpl<span class="w"> </span><span class="nv">$0</span>x23d,0x8<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span><span class="m">1698</span>:<span class="w"> </span><span class="m">00</span><span class="w"> </span> +<span class="w"> </span><span class="m">1699</span>:<span class="w"> </span>0f<span class="w"> </span><span class="m">84</span><span class="w"> </span>e8<span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>je<span class="w"> </span><span class="m">1787</span><span class="w"> </span><phase_3+0x14f> +<span class="w"> </span>169f:<span class="w"> </span>e8<span class="w"> </span>a6<span class="w"> </span><span class="m">06</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>call<span class="w"> </span>1d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span>16a4:<span class="w"> </span>b8<span class="w"> </span><span class="m">63</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x63,%eax +<span class="w"> </span>16a9:<span class="w"> </span>e9<span class="w"> </span>d9<span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>jmp<span class="w"> </span><span class="m">1787</span><span class="w"> </span><phase_3+0x14f> +<span class="w"> </span>16ae:<span class="w"> </span>b8<span class="w"> </span><span class="m">61</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x61,%eax +<span class="w"> </span>16b3:<span class="w"> </span><span class="m">81</span><span class="w"> </span>7c<span class="w"> </span><span class="m">24</span><span class="w"> </span><span class="m">08</span><span class="w"> </span><span class="m">27</span><span class="w"> </span><span class="m">01</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>cmpl<span class="w"> </span><span class="nv">$0</span>x127,0x8<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>16ba:<span class="w"> </span><span class="m">00</span><span class="w"> </span> +<span class="w"> </span>16bb:<span class="w"> </span>0f<span class="w"> </span><span class="m">84</span><span class="w"> </span>c6<span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>je<span class="w"> </span><span class="m">1787</span><span class="w"> </span><phase_3+0x14f> +<span class="w"> </span>16c1:<span class="w"> </span>e8<span class="w"> </span><span class="m">84</span><span class="w"> </span><span class="m">06</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>call<span class="w"> </span>1d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span>16c6:<span class="w"> </span>b8<span class="w"> </span><span class="m">61</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x61,%eax +<span class="w"> </span>16cb:<span class="w"> </span>e9<span class="w"> </span>b7<span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>jmp<span class="w"> </span><span class="m">1787</span><span class="w"> </span><phase_3+0x14f> +<span class="w"> </span>16d0:<span class="w"> </span>b8<span class="w"> </span><span class="m">78</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x78,%eax +<span class="w"> </span>16d5:<span class="w"> </span><span class="m">81</span><span class="w"> </span>7c<span class="w"> </span><span class="m">24</span><span class="w"> </span><span class="m">08</span><span class="w"> </span>e7<span class="w"> </span><span class="m">02</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>cmpl<span class="w"> </span><span class="nv">$0</span>x2e7,0x8<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>16dc:<span class="w"> </span><span class="m">00</span><span class="w"> </span> +<span class="w"> </span>16dd:<span class="w"> </span>0f<span class="w"> </span><span class="m">84</span><span class="w"> </span>a4<span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>je<span class="w"> </span><span class="m">1787</span><span class="w"> </span><phase_3+0x14f> +<span class="w"> </span>16e3:<span class="w"> </span>e8<span class="w"> </span><span class="m">62</span><span class="w"> </span><span class="m">06</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>call<span class="w"> </span>1d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span>16e8:<span class="w"> </span>b8<span class="w"> </span><span class="m">78</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x78,%eax +<span class="w"> </span>16ed:<span class="w"> </span>e9<span class="w"> </span><span class="m">95</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>jmp<span class="w"> </span><span class="m">1787</span><span class="w"> </span><phase_3+0x14f> +<span class="w"> </span>16f2:<span class="w"> </span>b8<span class="w"> </span><span class="m">64</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x64,%eax +<span class="w"> </span>16f7:<span class="w"> </span><span class="m">81</span><span class="w"> </span>7c<span class="w"> </span><span class="m">24</span><span class="w"> </span><span class="m">08</span><span class="w"> </span><span class="m">80</span><span class="w"> </span><span class="m">02</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>cmpl<span class="w"> </span><span class="nv">$0</span>x280,0x8<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>16fe:<span class="w"> </span><span class="m">00</span><span class="w"> </span> +<span class="w"> </span>16ff:<span class="w"> </span>0f<span class="w"> </span><span class="m">84</span><span class="w"> </span><span class="m">82</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>je<span class="w"> </span><span class="m">1787</span><span class="w"> </span><phase_3+0x14f> +<span class="w"> </span><span class="m">1705</span>:<span class="w"> </span>e8<span class="w"> </span><span class="m">40</span><span class="w"> </span><span class="m">06</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>call<span class="w"> </span>1d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span>170a:<span class="w"> </span>b8<span class="w"> </span><span class="m">64</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x64,%eax +<span class="w"> </span>170f:<span class="w"> </span>eb<span class="w"> </span><span class="m">76</span><span class="w"> </span>jmp<span class="w"> </span><span class="m">1787</span><span class="w"> </span><phase_3+0x14f> +<span class="w"> </span><span class="m">1711</span>:<span class="w"> </span>b8<span class="w"> </span>6d<span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x6d,%eax +<span class="w"> </span><span class="m">1716</span>:<span class="w"> </span><span class="m">81</span><span class="w"> </span>7c<span class="w"> </span><span class="m">24</span><span class="w"> </span><span class="m">08</span><span class="w"> </span>ff<span class="w"> </span><span class="m">02</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>cmpl<span class="w"> </span><span class="nv">$0</span>x2ff,0x8<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>171d:<span class="w"> </span><span class="m">00</span><span class="w"> </span> +<span class="w"> </span>171e:<span class="w"> </span><span class="m">74</span><span class="w"> </span><span class="m">67</span><span class="w"> </span>je<span class="w"> </span><span class="m">1787</span><span class="w"> </span><phase_3+0x14f> +<span class="w"> </span><span class="m">1720</span>:<span class="w"> </span>e8<span class="w"> </span><span class="m">25</span><span class="w"> </span><span class="m">06</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>call<span class="w"> </span>1d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span><span class="m">1725</span>:<span class="w"> </span>b8<span class="w"> </span>6d<span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x6d,%eax +<span class="w"> </span>172a:<span class="w"> </span>eb<span class="w"> </span>5b<span class="w"> </span>jmp<span class="w"> </span><span class="m">1787</span><span class="w"> </span><phase_3+0x14f> +<span class="w"> </span>172c:<span class="w"> </span>b8<span class="w"> </span><span class="m">71</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x71,%eax +<span class="w"> </span><span class="m">1731</span>:<span class="w"> </span><span class="m">81</span><span class="w"> </span>7c<span class="w"> </span><span class="m">24</span><span class="w"> </span><span class="m">08</span><span class="w"> </span><span class="m">75</span><span class="w"> </span><span class="m">03</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>cmpl<span class="w"> </span><span class="nv">$0</span>x375,0x8<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span><span class="m">1738</span>:<span class="w"> </span><span class="m">00</span><span class="w"> </span> +<span class="w"> </span><span class="m">1739</span>:<span class="w"> </span><span class="m">74</span><span class="w"> </span>4c<span class="w"> </span>je<span class="w"> </span><span class="m">1787</span><span class="w"> </span><phase_3+0x14f> +<span class="w"> </span>173b:<span class="w"> </span>e8<span class="w"> </span>0a<span class="w"> </span><span class="m">06</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>call<span class="w"> </span>1d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span><span class="m">1740</span>:<span class="w"> </span>b8<span class="w"> </span><span class="m">71</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x71,%eax +<span class="w"> </span><span class="m">1745</span>:<span class="w"> </span>eb<span class="w"> </span><span class="m">40</span><span class="w"> </span>jmp<span class="w"> </span><span class="m">1787</span><span class="w"> </span><phase_3+0x14f> +<span class="w"> </span><span class="m">1747</span>:<span class="w"> </span>b8<span class="w"> </span><span class="m">79</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x79,%eax +<span class="w"> </span>174c:<span class="w"> </span><span class="m">81</span><span class="w"> </span>7c<span class="w"> </span><span class="m">24</span><span class="w"> </span><span class="m">08</span><span class="w"> </span><span class="m">94</span><span class="w"> </span><span class="m">02</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>cmpl<span class="w"> </span><span class="nv">$0</span>x294,0x8<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span><span class="m">1753</span>:<span class="w"> </span><span class="m">00</span><span class="w"> </span> +<span class="w"> </span><span class="m">1754</span>:<span class="w"> </span><span class="m">74</span><span class="w"> </span><span class="m">31</span><span class="w"> </span>je<span class="w"> </span><span class="m">1787</span><span class="w"> </span><phase_3+0x14f> +<span class="w"> </span><span class="m">1756</span>:<span class="w"> </span>e8<span class="w"> </span>ef<span class="w"> </span><span class="m">05</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>call<span class="w"> </span>1d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span>175b:<span class="w"> </span>b8<span class="w"> </span><span class="m">79</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x79,%eax +<span class="w"> </span><span class="m">1760</span>:<span class="w"> </span>eb<span class="w"> </span><span class="m">25</span><span class="w"> </span>jmp<span class="w"> </span><span class="m">1787</span><span class="w"> </span><phase_3+0x14f> +<span class="w"> </span><span class="m">1762</span>:<span class="w"> </span>b8<span class="w"> </span><span class="m">79</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x79,%eax +<span class="w"> </span><span class="m">1767</span>:<span class="w"> </span><span class="m">81</span><span class="w"> </span>7c<span class="w"> </span><span class="m">24</span><span class="w"> </span><span class="m">08</span><span class="w"> </span><span class="m">88</span><span class="w"> </span><span class="m">02</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>cmpl<span class="w"> </span><span class="nv">$0</span>x288,0x8<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>176e:<span class="w"> </span><span class="m">00</span><span class="w"> </span> +<span class="w"> </span>176f:<span class="w"> </span><span class="m">74</span><span class="w"> </span><span class="m">16</span><span class="w"> </span>je<span class="w"> </span><span class="m">1787</span><span class="w"> </span><phase_3+0x14f> +<span class="w"> </span><span class="m">1771</span>:<span class="w"> </span>e8<span class="w"> </span>d4<span class="w"> </span><span class="m">05</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>call<span class="w"> </span>1d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span><span class="m">1776</span>:<span class="w"> </span>b8<span class="w"> </span><span class="m">79</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x79,%eax +<span class="w"> </span>177b:<span class="w"> </span>eb<span class="w"> </span>0a<span class="w"> </span>jmp<span class="w"> </span><span class="m">1787</span><span class="w"> </span><phase_3+0x14f> +<span class="w"> </span>177d:<span class="w"> </span>e8<span class="w"> </span>c8<span class="w"> </span><span class="m">05</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>call<span class="w"> </span>1d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span><span class="m">1782</span>:<span class="w"> </span>b8<span class="w"> </span><span class="m">68</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x68,%eax +<span class="w"> </span><span class="m">1787</span>:<span class="w"> </span><span class="m">38</span><span class="w"> </span><span class="m">44</span><span class="w"> </span><span class="m">24</span><span class="w"> </span><span class="m">07</span><span class="w"> </span>cmp<span class="w"> </span>%al,0x7<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>178b:<span class="w"> </span><span class="m">75</span><span class="w"> </span><span class="m">05</span><span class="w"> </span>jne<span class="w"> </span><span class="m">1792</span><span class="w"> </span><phase_3+0x15a> +<span class="w"> </span>178d:<span class="w"> </span><span class="m">48</span><span class="w"> </span><span class="m">83</span><span class="w"> </span>c4<span class="w"> </span><span class="m">18</span><span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x18,%rsp +<span class="w"> </span><span class="m">1791</span>:<span class="w"> </span>c3<span class="w"> </span>ret<span class="w"> </span> +<span class="w"> </span><span class="m">1792</span>:<span class="w"> </span>e8<span class="w"> </span>b3<span class="w"> </span><span class="m">05</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>call<span class="w"> </span>1d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span><span class="m">1797</span>:<span class="w"> </span>eb<span class="w"> </span>f4<span class="w"> </span>jmp<span class="w"> </span>178d<span class="w"> </span><phase_3+0x155> </code></pre> </div> <div class="codehilite"> <pre><span></span><code>... - 165b: e8 <span class="m">80</span> <span class="nb">fc</span> ff ff call 12e0 <__isoc99_sscanf@plt> +<span class="w"> </span>165b:<span class="w"> </span>e8<span class="w"> </span><span class="m">80</span><span class="w"> </span><span class="nb">fc</span><span class="w"> </span>ff<span class="w"> </span>ff<span class="w"> </span>call<span class="w"> </span>12e0<span class="w"> </span><__isoc99_sscanf@plt> ... </code></pre> </div> @@ -3515,82 +3519,82 @@ That<span class="err">'</span>s number <span class="m">2</span>. Keep going <p>Because I do not want to enter the solutions to phases 1 and 2 again and again, I am goig to pass a file which has these solutions.</p> <div class="codehilite"> -<pre><span></span><code>joxxxn@jupyter-nxxh6xx8:~/lab2-bomblab-navanchauhan/bombbomb$ gdb -ex <span class="s1">'break phase_3'</span> -ex <span class="s1">'break explode_bomb'</span> -ex <span class="s1">'run'</span> -args ./bomb sol.txt -GNU gdb <span class="o">(</span>Ubuntu <span class="m">12</span>.1-0ubuntu1~22.04<span class="o">)</span> <span class="m">12</span>.1 -Copyright <span class="o">(</span>C<span class="o">)</span> <span class="m">2022</span> Free Software Foundation, Inc. -License GPLv3+: GNU GPL version <span class="m">3</span> or later <http://gnu.org/licenses/gpl.html> -This is free software: you are free to change and redistribute it. -There is NO WARRANTY, to the extent permitted by law. -Type <span class="s2">"show copying"</span> and <span class="s2">"show warranty"</span> <span class="k">for</span> details. -This GDB was configured as <span class="s2">"x86_64-linux-gnu"</span>. -Type <span class="s2">"show configuration"</span> <span class="k">for</span> configuration details. -For bug reporting instructions, please see: +<pre><span></span><code>joxxxn@jupyter-nxxh6xx8:~/lab2-bomblab-navanchauhan/bombbomb$<span class="w"> </span>gdb<span class="w"> </span>-ex<span class="w"> </span><span class="s1">'break phase_3'</span><span class="w"> </span>-ex<span class="w"> </span><span class="s1">'break explode_bomb'</span><span class="w"> </span>-ex<span class="w"> </span><span class="s1">'run'</span><span class="w"> </span>-args<span class="w"> </span>./bomb<span class="w"> </span>sol.txt<span class="w"> </span> +GNU<span class="w"> </span>gdb<span class="w"> </span><span class="o">(</span>Ubuntu<span class="w"> </span><span class="m">12</span>.1-0ubuntu1~22.04<span class="o">)</span><span class="w"> </span><span class="m">12</span>.1 +Copyright<span class="w"> </span><span class="o">(</span>C<span class="o">)</span><span class="w"> </span><span class="m">2022</span><span class="w"> </span>Free<span class="w"> </span>Software<span class="w"> </span>Foundation,<span class="w"> </span>Inc. +License<span class="w"> </span>GPLv3+:<span class="w"> </span>GNU<span class="w"> </span>GPL<span class="w"> </span>version<span class="w"> </span><span class="m">3</span><span class="w"> </span>or<span class="w"> </span>later<span class="w"> </span><http://gnu.org/licenses/gpl.html> +This<span class="w"> </span>is<span class="w"> </span>free<span class="w"> </span>software:<span class="w"> </span>you<span class="w"> </span>are<span class="w"> </span>free<span class="w"> </span>to<span class="w"> </span>change<span class="w"> </span>and<span class="w"> </span>redistribute<span class="w"> </span>it. +There<span class="w"> </span>is<span class="w"> </span>NO<span class="w"> </span>WARRANTY,<span class="w"> </span>to<span class="w"> </span>the<span class="w"> </span>extent<span class="w"> </span>permitted<span class="w"> </span>by<span class="w"> </span>law. +Type<span class="w"> </span><span class="s2">"show copying"</span><span class="w"> </span>and<span class="w"> </span><span class="s2">"show warranty"</span><span class="w"> </span><span class="k">for</span><span class="w"> </span>details. +This<span class="w"> </span>GDB<span class="w"> </span>was<span class="w"> </span>configured<span class="w"> </span>as<span class="w"> </span><span class="s2">"x86_64-linux-gnu"</span>. +Type<span class="w"> </span><span class="s2">"show configuration"</span><span class="w"> </span><span class="k">for</span><span class="w"> </span>configuration<span class="w"> </span>details. +For<span class="w"> </span>bug<span class="w"> </span>reporting<span class="w"> </span>instructions,<span class="w"> </span>please<span class="w"> </span>see: <https://www.gnu.org/software/gdb/bugs/>. -Find the GDB manual and other documentation resources online at: - <http://www.gnu.org/software/gdb/documentation/>. - -For help, <span class="nb">type</span> <span class="s2">"help"</span>. -Type <span class="s2">"apropos word"</span> to search <span class="k">for</span> commands related to <span class="s2">"word"</span>... -Reading symbols from ./bomb... -Breakpoint <span class="m">1</span> at 0x1638 -Breakpoint <span class="m">2</span> at 0x1d4a -Starting program: /home/joxxxn/lab2-bomblab-navanchauhan/bombbomb/bomb sol.txt -<span class="o">[</span>Thread debugging using libthread_db enabled<span class="o">]</span> -Using host libthread_db library <span class="s2">"/lib/x86_64-linux-gnu/libthread_db.so.1"</span>. -Welcome to my fiendish little bomb. You have <span class="m">6</span> phases with -which to blow yourself up. Have a nice day! -Phase <span class="m">1</span> defused. How about the next one? -That<span class="err">'</span>s number <span class="m">2</span>. Keep going! -random string - -Breakpoint <span class="m">1</span>, 0x0000555555555638 <span class="k">in</span> phase_3 <span class="o">()</span> -<span class="o">(</span>gdb<span class="o">)</span> disas -Dump of assembler code <span class="k">for</span> <span class="k">function</span> phase_3: -<span class="o">=</span>> 0x0000555555555638 <+0>: endbr64 - 0x000055555555563c <+4>: sub <span class="nv">$0</span>x18,%rsp - 0x0000555555555640 <+8>: lea 0x7<span class="o">(</span>%rsp<span class="o">)</span>,%rcx - 0x0000555555555645 <+13>: lea 0xc<span class="o">(</span>%rsp<span class="o">)</span>,%rdx - 0x000055555555564a <+18>: lea 0x8<span class="o">(</span>%rsp<span class="o">)</span>,%r8 - 0x000055555555564f <+23>: lea 0x1b60<span class="o">(</span>%rip<span class="o">)</span>,%rsi <span class="c1"># 0x5555555571b6</span> - 0x0000555555555656 <+30>: mov <span class="nv">$0</span>x0,%eax - 0x000055555555565b <+35>: call 0x5555555552e0 <__isoc99_sscanf@plt> - 0x0000555555555660 <+40>: cmp <span class="nv">$0</span>x2,%eax - 0x0000555555555663 <+43>: jle 0x555555555685 <phase_3+77> - 0x0000555555555665 <+45>: cmpl <span class="nv">$0</span>x7,0xc<span class="o">(</span>%rsp<span class="o">)</span> - 0x000055555555566a <+50>: ja 0x55555555577d <phase_3+325> - 0x0000555555555670 <+56>: mov 0xc<span class="o">(</span>%rsp<span class="o">)</span>,%eax - 0x0000555555555674 <+60>: lea 0x1b55<span class="o">(</span>%rip<span class="o">)</span>,%rdx <span class="c1"># 0x5555555571d0</span> - 0x000055555555567b <+67>: movslq <span class="o">(</span>%rdx,%rax,4<span class="o">)</span>,%rax - 0x000055555555567f <+71>: add %rdx,%rax - 0x0000555555555682 <+74>: notrack jmp *%rax - 0x0000555555555685 <+77>: call 0x555555555d4a <explode_bomb> - 0x000055555555568a <+82>: jmp 0x555555555665 <phase_3+45> - 0x000055555555568c <+84>: mov <span class="nv">$0</span>x63,%eax - 0x0000555555555691 <+89>: cmpl <span class="nv">$0</span>x23d,0x8<span class="o">(</span>%rsp<span class="o">)</span> - 0x0000555555555699 <+97>: je 0x555555555787 <phase_3+335> - 0x000055555555569f <+103>: call 0x555555555d4a <explode_bomb> - 0x00005555555556a4 <+108>: mov <span class="nv">$0</span>x63,%eax - 0x00005555555556a9 <+113>: jmp 0x555555555787 <phase_3+335> ---Type <RET> <span class="k">for</span> more, q to quit, c to <span class="k">continue</span> without paging-- +Find<span class="w"> </span>the<span class="w"> </span>GDB<span class="w"> </span>manual<span class="w"> </span>and<span class="w"> </span>other<span class="w"> </span>documentation<span class="w"> </span>resources<span class="w"> </span>online<span class="w"> </span>at: +<span class="w"> </span><http://www.gnu.org/software/gdb/documentation/>. + +For<span class="w"> </span>help,<span class="w"> </span><span class="nb">type</span><span class="w"> </span><span class="s2">"help"</span>. +Type<span class="w"> </span><span class="s2">"apropos word"</span><span class="w"> </span>to<span class="w"> </span>search<span class="w"> </span><span class="k">for</span><span class="w"> </span>commands<span class="w"> </span>related<span class="w"> </span>to<span class="w"> </span><span class="s2">"word"</span>... +Reading<span class="w"> </span>symbols<span class="w"> </span>from<span class="w"> </span>./bomb... +Breakpoint<span class="w"> </span><span class="m">1</span><span class="w"> </span>at<span class="w"> </span>0x1638 +Breakpoint<span class="w"> </span><span class="m">2</span><span class="w"> </span>at<span class="w"> </span>0x1d4a +Starting<span class="w"> </span>program:<span class="w"> </span>/home/joxxxn/lab2-bomblab-navanchauhan/bombbomb/bomb<span class="w"> </span>sol.txt +<span class="o">[</span>Thread<span class="w"> </span>debugging<span class="w"> </span>using<span class="w"> </span>libthread_db<span class="w"> </span>enabled<span class="o">]</span> +Using<span class="w"> </span>host<span class="w"> </span>libthread_db<span class="w"> </span>library<span class="w"> </span><span class="s2">"/lib/x86_64-linux-gnu/libthread_db.so.1"</span>. +Welcome<span class="w"> </span>to<span class="w"> </span>my<span class="w"> </span>fiendish<span class="w"> </span>little<span class="w"> </span>bomb.<span class="w"> </span>You<span class="w"> </span>have<span class="w"> </span><span class="m">6</span><span class="w"> </span>phases<span class="w"> </span>with +which<span class="w"> </span>to<span class="w"> </span>blow<span class="w"> </span>yourself<span class="w"> </span>up.<span class="w"> </span>Have<span class="w"> </span>a<span class="w"> </span>nice<span class="w"> </span>day! +Phase<span class="w"> </span><span class="m">1</span><span class="w"> </span>defused.<span class="w"> </span>How<span class="w"> </span>about<span class="w"> </span>the<span class="w"> </span>next<span class="w"> </span>one? +That<span class="err">'</span>s<span class="w"> </span>number<span class="w"> </span><span class="m">2</span>.<span class="w"> </span>Keep<span class="w"> </span>going! +random<span class="w"> </span>string + +Breakpoint<span class="w"> </span><span class="m">1</span>,<span class="w"> </span>0x0000555555555638<span class="w"> </span><span class="k">in</span><span class="w"> </span>phase_3<span class="w"> </span><span class="o">()</span> +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span>disas +Dump<span class="w"> </span>of<span class="w"> </span>assembler<span class="w"> </span>code<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="k">function</span><span class="w"> </span>phase_3: +<span class="o">=</span>><span class="w"> </span>0x0000555555555638<span class="w"> </span><+0>:<span class="w"> </span>endbr64<span class="w"> </span> +<span class="w"> </span>0x000055555555563c<span class="w"> </span><+4>:<span class="w"> </span>sub<span class="w"> </span><span class="nv">$0</span>x18,%rsp +<span class="w"> </span>0x0000555555555640<span class="w"> </span><+8>:<span class="w"> </span>lea<span class="w"> </span>0x7<span class="o">(</span>%rsp<span class="o">)</span>,%rcx +<span class="w"> </span>0x0000555555555645<span class="w"> </span><+13>:<span class="w"> </span>lea<span class="w"> </span>0xc<span class="o">(</span>%rsp<span class="o">)</span>,%rdx +<span class="w"> </span>0x000055555555564a<span class="w"> </span><+18>:<span class="w"> </span>lea<span class="w"> </span>0x8<span class="o">(</span>%rsp<span class="o">)</span>,%r8 +<span class="w"> </span>0x000055555555564f<span class="w"> </span><+23>:<span class="w"> </span>lea<span class="w"> </span>0x1b60<span class="o">(</span>%rip<span class="o">)</span>,%rsi<span class="w"> </span><span class="c1"># 0x5555555571b6</span> +<span class="w"> </span>0x0000555555555656<span class="w"> </span><+30>:<span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x0,%eax +<span class="w"> </span>0x000055555555565b<span class="w"> </span><+35>:<span class="w"> </span>call<span class="w"> </span>0x5555555552e0<span class="w"> </span><__isoc99_sscanf@plt> +<span class="w"> </span>0x0000555555555660<span class="w"> </span><+40>:<span class="w"> </span>cmp<span class="w"> </span><span class="nv">$0</span>x2,%eax +<span class="w"> </span>0x0000555555555663<span class="w"> </span><+43>:<span class="w"> </span>jle<span class="w"> </span>0x555555555685<span class="w"> </span><phase_3+77> +<span class="w"> </span>0x0000555555555665<span class="w"> </span><+45>:<span class="w"> </span>cmpl<span class="w"> </span><span class="nv">$0</span>x7,0xc<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>0x000055555555566a<span class="w"> </span><+50>:<span class="w"> </span>ja<span class="w"> </span>0x55555555577d<span class="w"> </span><phase_3+325> +<span class="w"> </span>0x0000555555555670<span class="w"> </span><+56>:<span class="w"> </span>mov<span class="w"> </span>0xc<span class="o">(</span>%rsp<span class="o">)</span>,%eax +<span class="w"> </span>0x0000555555555674<span class="w"> </span><+60>:<span class="w"> </span>lea<span class="w"> </span>0x1b55<span class="o">(</span>%rip<span class="o">)</span>,%rdx<span class="w"> </span><span class="c1"># 0x5555555571d0</span> +<span class="w"> </span>0x000055555555567b<span class="w"> </span><+67>:<span class="w"> </span>movslq<span class="w"> </span><span class="o">(</span>%rdx,%rax,4<span class="o">)</span>,%rax +<span class="w"> </span>0x000055555555567f<span class="w"> </span><+71>:<span class="w"> </span>add<span class="w"> </span>%rdx,%rax +<span class="w"> </span>0x0000555555555682<span class="w"> </span><+74>:<span class="w"> </span>notrack<span class="w"> </span>jmp<span class="w"> </span>*%rax +<span class="w"> </span>0x0000555555555685<span class="w"> </span><+77>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span>0x000055555555568a<span class="w"> </span><+82>:<span class="w"> </span>jmp<span class="w"> </span>0x555555555665<span class="w"> </span><phase_3+45> +<span class="w"> </span>0x000055555555568c<span class="w"> </span><+84>:<span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x63,%eax +<span class="w"> </span>0x0000555555555691<span class="w"> </span><+89>:<span class="w"> </span>cmpl<span class="w"> </span><span class="nv">$0</span>x23d,0x8<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>0x0000555555555699<span class="w"> </span><+97>:<span class="w"> </span>je<span class="w"> </span>0x555555555787<span class="w"> </span><phase_3+335> +<span class="w"> </span>0x000055555555569f<span class="w"> </span><+103>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span>0x00005555555556a4<span class="w"> </span><+108>:<span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x63,%eax +<span class="w"> </span>0x00005555555556a9<span class="w"> </span><+113>:<span class="w"> </span>jmp<span class="w"> </span>0x555555555787<span class="w"> </span><phase_3+335> +--Type<span class="w"> </span><RET><span class="w"> </span><span class="k">for</span><span class="w"> </span>more,<span class="w"> </span>q<span class="w"> </span>to<span class="w"> </span>quit,<span class="w"> </span>c<span class="w"> </span>to<span class="w"> </span><span class="k">continue</span><span class="w"> </span>without<span class="w"> </span>paging-- </code></pre> </div> <p><code>gdb</code> has thankfully marked the address which is being passed to <code>scanf</code>. We can access the value:</p> <div class="codehilite"> -<pre><span></span><code><span class="o">(</span>gdb<span class="o">)</span> x/1s 0x5555555571b6 -0x5555555571b6: <span class="s2">"%d %c %d"</span> -<span class="o">(</span>gdb<span class="o">)</span> +<pre><span></span><code><span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span>x/1s<span class="w"> </span>0x5555555571b6 +0x5555555571b6:<span class="w"> </span><span class="s2">"%d %c %d"</span> +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span> </code></pre> </div> <p>BINGO! The program expects an integer, character, and another integer. Onwards.</p> <div class="codehilite"> -<pre><span></span><code> 0x0000555555555660 <+40>: cmp <span class="nv">$0</span>x2,%eax - 0x0000555555555663 <+43>: jle 0x555555555685 <phase_3+77> +<pre><span></span><code><span class="w"> </span>0x0000555555555660<span class="w"> </span><+40>:<span class="w"> </span>cmp<span class="w"> </span><span class="nv">$0</span>x2,%eax +<span class="w"> </span>0x0000555555555663<span class="w"> </span><+43>:<span class="w"> </span>jle<span class="w"> </span>0x555555555685<span class="w"> </span><phase_3+77> ... - 0x0000555555555685 <+77>: call 0x555555555d4a <explode_bomb> +<span class="w"> </span>0x0000555555555685<span class="w"> </span><+77>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> </code></pre> </div> @@ -3599,23 +3603,24 @@ Dump of assembler code <span class="k">for</span> <span class="k">function</span <p><em>Note: <code>scanf</code> returns the number of fields that were succesfully converted and assigned</em></p> <div class="codehilite"> -<pre><span></span><code> 0x0000555555555665 <+45>: cmpl <span class="nv">$0</span>x7,0xc<span class="o">(</span>%rsp<span class="o">)</span> - 0x000055555555566a <+50>: ja 0x55555555577d <phase_3+325> +<pre><span></span><code><span class="w"> </span>0x0000555555555665<span class="w"> </span><+45>:<span class="w"> </span>cmpl<span class="w"> </span><span class="nv">$0</span>x7,0xc<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>0x000055555555566a<span class="w"> </span><+50>:<span class="w"> </span>ja<span class="w"> </span>0x55555555577d<span class="w"> </span><phase_3+325> ... - 0x000055555555577d <+325>: call 0x555555555d4a <explode_bomb> +<span class="w"> </span>0x000055555555577d<span class="w"> </span><+325>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> </code></pre> </div> -<p>Similarly, the program checks and ensures the returned value is not > 7. - <div class="codehilite"> - <pre><span></span><code>0x0000555555555670 <+56>: mov 0xc<span class="o">(</span>%rsp<span class="o">)</span>,%eax - 0x0000555555555674 <+60>: lea 0x1b55<span class="o">(</span>%rip<span class="o">)</span>,%rdx <span class="c1"># 0x5555555571d0</span> - 0x000055555555567b <+67>: movslq <span class="o">(</span>%rdx,%rax,4<span class="o">)</span>,%rax - 0x000055555555567f <+71>: add %rdx,%rax - 0x0000555555555682 <+74>: notrack jmp *%rax - 0x0000555555555685 <+77>: call 0x555555555d4a <explode_bomb> - </code></pre> - </div></p> +<p>Similarly, the program checks and ensures the returned value is not > 7. </p> + +<div class="codehilite"> +<pre><span></span><code><span class="w"> </span>0x0000555555555670<span class="w"> </span><+56>:<span class="w"> </span>mov<span class="w"> </span>0xc<span class="o">(</span>%rsp<span class="o">)</span>,%eax +<span class="w"> </span>0x0000555555555674<span class="w"> </span><+60>:<span class="w"> </span>lea<span class="w"> </span>0x1b55<span class="o">(</span>%rip<span class="o">)</span>,%rdx<span class="w"> </span><span class="c1"># 0x5555555571d0</span> +<span class="w"> </span>0x000055555555567b<span class="w"> </span><+67>:<span class="w"> </span>movslq<span class="w"> </span><span class="o">(</span>%rdx,%rax,4<span class="o">)</span>,%rax +<span class="w"> </span>0x000055555555567f<span class="w"> </span><+71>:<span class="w"> </span>add<span class="w"> </span>%rdx,%rax +<span class="w"> </span>0x0000555555555682<span class="w"> </span><+74>:<span class="w"> </span>notrack<span class="w"> </span>jmp<span class="w"> </span>*%rax +<span class="w"> </span>0x0000555555555685<span class="w"> </span><+77>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> +</code></pre> +</div> <ul> <li><code>0x0000555555555670 <+56>: mov 0xc(%rsp),%eax</code> - Moves value located at <code>0xc</code> (12 in Decimal) bytes above the stack pointer to <code>%eax</code> register. </li> @@ -3645,34 +3650,36 @@ $1 = 3 <p><img src="/assets/bomb-lab/phase-3.png" alt="Screenshot of GDB terminal depicting us checking the value of the instruction to be jumped to" /></p> -<p>We can see that this makes us jump to <code><phase_3+186></code> (Continue to step through the code by using <code>ni</code>) - <div class="codehilite"> - <pre><span></span><code>0x00005555555556f2 <+186>: mov <span class="nv">$0</span>x64,%eax - 0x00005555555556f7 <+191>: cmpl <span class="nv">$0</span>x280,0x8<span class="o">(</span>%rsp<span class="o">)</span> - 0x00005555555556ff <+199>: je 0x555555555787 <phase<em>3+335> - 0x0000555555555705 <+205>: call 0x555555555d4a <explode</em>bomb> - </code></pre> - </div></p> - -<p>We see that <code>0x64</code> (Decimal 100) is being stored in <code>%eax</code>. Then, the program compares <code>0x280</code> (Decimal 640) with memory address <code>0x8</code> bytes above the stack pointer (<code>%rsp</code>). If the values are equal, then it jumps to <code><phase_3+335></code>, otherwise <code>explode_bomb</code> is called. - <div class="codehilite"> - <pre><span></span><code>0x0000555555555787 <+335>: cmp %al,0x7<span class="o">(</span>%rsp<span class="o">)</span> - 0x000055555555578b <+339>: jne 0x555555555792 <phase<em>3+346> - 0x000055555555578d <+341>: add <span class="nv">$0</span>x18,%rsp - 0x0000555555555791 <+345>: ret <br /> - 0x0000555555555792 <+346>: call 0x555555555d4a <explode</em>bomb> - </code></pre> - </div></p> +<p>We can see that this makes us jump to <code><phase_3+186></code> (Continue to step through the code by using <code>ni</code>)</p> + +<div class="codehilite"> +<pre><span></span><code><span class="w"> </span>0x00005555555556f2<span class="w"> </span><+186>:<span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x64,%eax +<span class="w"> </span>0x00005555555556f7<span class="w"> </span><+191>:<span class="w"> </span>cmpl<span class="w"> </span><span class="nv">$0</span>x280,0x8<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>0x00005555555556ff<span class="w"> </span><+199>:<span class="w"> </span>je<span class="w"> </span>0x555555555787<span class="w"> </span><phase_3+335> +<span class="w"> </span>0x0000555555555705<span class="w"> </span><+205>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> +</code></pre> +</div> + +<p>We see that <code>0x64</code> (Decimal 100) is being stored in <code>%eax</code>. Then, the program compares <code>0x280</code> (Decimal 640) with memory address <code>0x8</code> bytes above the stack pointer (<code>%rsp</code>). If the values are equal, then it jumps to <code><phase_3+335></code>, otherwise <code>explode_bomb</code> is called.</p> + +<div class="codehilite"> +<pre><span></span><code><span class="w"> </span>0x0000555555555787<span class="w"> </span><+335>:<span class="w"> </span>cmp<span class="w"> </span>%al,0x7<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>0x000055555555578b<span class="w"> </span><+339>:<span class="w"> </span>jne<span class="w"> </span>0x555555555792<span class="w"> </span><phase_3+346> +<span class="w"> </span>0x000055555555578d<span class="w"> </span><+341>:<span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x18,%rsp +<span class="w"> </span>0x0000555555555791<span class="w"> </span><+345>:<span class="w"> </span>ret<span class="w"> </span> +<span class="w"> </span>0x0000555555555792<span class="w"> </span><+346>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> +</code></pre> +</div> <p>Here, the program is comparing the value of our given character to the value stored in <code>%al</code> (lower 8 bits of <code>EAX</code>), and checks if they are not equal.</p> <p>Knowing that the character is stored at an offset of 7 bytes to <code>%rsp</code>, we can print and check the value by running:</p> <div class="codehilite"> -<pre><span></span><code><span class="o">(</span>gdb<span class="o">)</span> x/1cw <span class="nv">$rsp</span>+7 +<pre><span></span><code><span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span>x/1cw<span class="w"> </span><span class="nv">$rsp</span>+7 c -<span class="o">(</span>gdb<span class="o">)</span> print <span class="nv">$al</span> -<span class="nv">$1</span> <span class="o">=</span> <span class="m">100</span> +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span>print<span class="w"> </span><span class="nv">$al</span> +<span class="nv">$1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="m">100</span> </code></pre> </div> @@ -3680,114 +3687,116 @@ c <div class="codehilite"> <pre><span></span><code>... -That<span class="err">'</span>s number <span class="m">2</span>. Keep going! -<span class="m">3</span> d <span class="m">640</span> +That<span class="err">'</span>s<span class="w"> </span>number<span class="w"> </span><span class="m">2</span>.<span class="w"> </span>Keep<span class="w"> </span>going! +<span class="m">3</span><span class="w"> </span>d<span class="w"> </span><span class="m">640</span> -Breakpoint <span class="m">1</span>, 0x0000555555555638 <span class="k">in</span> phase_3 <span class="o">()</span> -<span class="o">(</span>gdb<span class="o">)</span> <span class="k">continue</span> +Breakpoint<span class="w"> </span><span class="m">1</span>,<span class="w"> </span>0x0000555555555638<span class="w"> </span><span class="k">in</span><span class="w"> </span>phase_3<span class="w"> </span><span class="o">()</span> +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span><span class="k">continue</span> Continuing. -Halfway there! +Halfway<span class="w"> </span>there! </code></pre> </div> <h2>Phase 4</h2> <div class="codehilite"> -<pre><span></span><code>joxxxn@jupyter-nxxh6xx8:~/lab2-bomblab-navanchauhan/bombbomb$ gdb -ex <span class="s1">'break phase_4'</span> -ex <span class="s1">'break explode_bomb'</span> -ex <span class="s1">'run'</span> -args ./bomb sol.txt -GNU gdb <span class="o">(</span>Ubuntu <span class="m">12</span>.1-0ubuntu1~22.04<span class="o">)</span> <span class="m">12</span>.1 -Copyright <span class="o">(</span>C<span class="o">)</span> <span class="m">2022</span> Free Software Foundation, Inc. -License GPLv3+: GNU GPL version <span class="m">3</span> or later <http://gnu.org/licenses/gpl.html> -This is free software: you are free to change and redistribute it. -There is NO WARRANTY, to the extent permitted by law. -Type <span class="s2">"show copying"</span> and <span class="s2">"show warranty"</span> <span class="k">for</span> details. -This GDB was configured as <span class="s2">"x86_64-linux-gnu"</span>. -Type <span class="s2">"show configuration"</span> <span class="k">for</span> configuration details. -For bug reporting instructions, please see: +<pre><span></span><code>joxxxn@jupyter-nxxh6xx8:~/lab2-bomblab-navanchauhan/bombbomb$<span class="w"> </span>gdb<span class="w"> </span>-ex<span class="w"> </span><span class="s1">'break phase_4'</span><span class="w"> </span>-ex<span class="w"> </span><span class="s1">'break explode_bomb'</span><span class="w"> </span>-ex<span class="w"> </span><span class="s1">'run'</span><span class="w"> </span>-args<span class="w"> </span>./bomb<span class="w"> </span>sol.txt<span class="w"> </span> +GNU<span class="w"> </span>gdb<span class="w"> </span><span class="o">(</span>Ubuntu<span class="w"> </span><span class="m">12</span>.1-0ubuntu1~22.04<span class="o">)</span><span class="w"> </span><span class="m">12</span>.1 +Copyright<span class="w"> </span><span class="o">(</span>C<span class="o">)</span><span class="w"> </span><span class="m">2022</span><span class="w"> </span>Free<span class="w"> </span>Software<span class="w"> </span>Foundation,<span class="w"> </span>Inc. +License<span class="w"> </span>GPLv3+:<span class="w"> </span>GNU<span class="w"> </span>GPL<span class="w"> </span>version<span class="w"> </span><span class="m">3</span><span class="w"> </span>or<span class="w"> </span>later<span class="w"> </span><http://gnu.org/licenses/gpl.html> +This<span class="w"> </span>is<span class="w"> </span>free<span class="w"> </span>software:<span class="w"> </span>you<span class="w"> </span>are<span class="w"> </span>free<span class="w"> </span>to<span class="w"> </span>change<span class="w"> </span>and<span class="w"> </span>redistribute<span class="w"> </span>it. +There<span class="w"> </span>is<span class="w"> </span>NO<span class="w"> </span>WARRANTY,<span class="w"> </span>to<span class="w"> </span>the<span class="w"> </span>extent<span class="w"> </span>permitted<span class="w"> </span>by<span class="w"> </span>law. +Type<span class="w"> </span><span class="s2">"show copying"</span><span class="w"> </span>and<span class="w"> </span><span class="s2">"show warranty"</span><span class="w"> </span><span class="k">for</span><span class="w"> </span>details. +This<span class="w"> </span>GDB<span class="w"> </span>was<span class="w"> </span>configured<span class="w"> </span>as<span class="w"> </span><span class="s2">"x86_64-linux-gnu"</span>. +Type<span class="w"> </span><span class="s2">"show configuration"</span><span class="w"> </span><span class="k">for</span><span class="w"> </span>configuration<span class="w"> </span>details. +For<span class="w"> </span>bug<span class="w"> </span>reporting<span class="w"> </span>instructions,<span class="w"> </span>please<span class="w"> </span>see: <https://www.gnu.org/software/gdb/bugs/>. -Find the GDB manual and other documentation resources online at: - <http://www.gnu.org/software/gdb/documentation/>. - -For help, <span class="nb">type</span> <span class="s2">"help"</span>. -Type <span class="s2">"apropos word"</span> to search <span class="k">for</span> commands related to <span class="s2">"word"</span>... -Reading symbols from ./bomb... -Breakpoint <span class="m">1</span> at 0x17d3 -Breakpoint <span class="m">2</span> at 0x1d4a -Starting program: /home/joxxxn/lab2-bomblab-navanchauhan/bombbomb/bomb sol.txt -<span class="o">[</span>Thread debugging using libthread_db enabled<span class="o">]</span> -Using host libthread_db library <span class="s2">"/lib/x86_64-linux-gnu/libthread_db.so.1"</span>. -Welcome to my fiendish little bomb. You have <span class="m">6</span> phases with -which to blow yourself up. Have a nice day! -Phase <span class="m">1</span> defused. How about the next one? -That<span class="err">'</span>s number <span class="m">2</span>. Keep going! -Halfway there! -<span class="nb">test</span> string - -Breakpoint <span class="m">1</span>, 0x00005555555557d3 <span class="k">in</span> phase_4 <span class="o">()</span> -<span class="o">(</span>gdb<span class="o">)</span> disas phase_4 -Dump of assembler code <span class="k">for</span> <span class="k">function</span> phase_4: -<span class="o">=</span>> 0x00005555555557d3 <+0>: endbr64 - 0x00005555555557d7 <+4>: sub <span class="nv">$0</span>x18,%rsp - 0x00005555555557db <+8>: lea 0x8<span class="o">(</span>%rsp<span class="o">)</span>,%rcx - 0x00005555555557e0 <+13>: lea 0xc<span class="o">(</span>%rsp<span class="o">)</span>,%rdx - 0x00005555555557e5 <+18>: lea 0x1bba<span class="o">(</span>%rip<span class="o">)</span>,%rsi <span class="c1"># 0x5555555573a6</span> - 0x00005555555557ec <+25>: mov <span class="nv">$0</span>x0,%eax - 0x00005555555557f1 <+30>: call 0x5555555552e0 <__isoc99_sscanf@plt> - 0x00005555555557f6 <+35>: cmp <span class="nv">$0</span>x2,%eax - 0x00005555555557f9 <+38>: jne 0x555555555802 <phase_4+47> - 0x00005555555557fb <+40>: cmpl <span class="nv">$0</span>xe,0xc<span class="o">(</span>%rsp<span class="o">)</span> - 0x0000555555555800 <+45>: jbe 0x555555555807 <phase_4+52> - 0x0000555555555802 <+47>: call 0x555555555d4a <explode_bomb> - 0x0000555555555807 <+52>: mov <span class="nv">$0</span>xe,%edx - 0x000055555555580c <+57>: mov <span class="nv">$0</span>x0,%esi - 0x0000555555555811 <+62>: mov 0xc<span class="o">(</span>%rsp<span class="o">)</span>,%edi - 0x0000555555555815 <+66>: call 0x555555555799 <func4> - 0x000055555555581a <+71>: cmp <span class="nv">$0</span>x2,%eax - 0x000055555555581d <+74>: jne 0x555555555826 <phase_4+83> - 0x000055555555581f <+76>: cmpl <span class="nv">$0</span>x2,0x8<span class="o">(</span>%rsp<span class="o">)</span> - 0x0000555555555824 <+81>: je 0x55555555582b <phase_4+88> - 0x0000555555555826 <+83>: call 0x555555555d4a <explode_bomb> - 0x000055555555582b <+88>: add <span class="nv">$0</span>x18,%rsp - 0x000055555555582f <+92>: ret -End of assembler dump. -<span class="o">(</span>gdb<span class="o">)</span> +Find<span class="w"> </span>the<span class="w"> </span>GDB<span class="w"> </span>manual<span class="w"> </span>and<span class="w"> </span>other<span class="w"> </span>documentation<span class="w"> </span>resources<span class="w"> </span>online<span class="w"> </span>at: +<span class="w"> </span><http://www.gnu.org/software/gdb/documentation/>. + +For<span class="w"> </span>help,<span class="w"> </span><span class="nb">type</span><span class="w"> </span><span class="s2">"help"</span>. +Type<span class="w"> </span><span class="s2">"apropos word"</span><span class="w"> </span>to<span class="w"> </span>search<span class="w"> </span><span class="k">for</span><span class="w"> </span>commands<span class="w"> </span>related<span class="w"> </span>to<span class="w"> </span><span class="s2">"word"</span>... +Reading<span class="w"> </span>symbols<span class="w"> </span>from<span class="w"> </span>./bomb... +Breakpoint<span class="w"> </span><span class="m">1</span><span class="w"> </span>at<span class="w"> </span>0x17d3 +Breakpoint<span class="w"> </span><span class="m">2</span><span class="w"> </span>at<span class="w"> </span>0x1d4a +Starting<span class="w"> </span>program:<span class="w"> </span>/home/joxxxn/lab2-bomblab-navanchauhan/bombbomb/bomb<span class="w"> </span>sol.txt +<span class="o">[</span>Thread<span class="w"> </span>debugging<span class="w"> </span>using<span class="w"> </span>libthread_db<span class="w"> </span>enabled<span class="o">]</span> +Using<span class="w"> </span>host<span class="w"> </span>libthread_db<span class="w"> </span>library<span class="w"> </span><span class="s2">"/lib/x86_64-linux-gnu/libthread_db.so.1"</span>. +Welcome<span class="w"> </span>to<span class="w"> </span>my<span class="w"> </span>fiendish<span class="w"> </span>little<span class="w"> </span>bomb.<span class="w"> </span>You<span class="w"> </span>have<span class="w"> </span><span class="m">6</span><span class="w"> </span>phases<span class="w"> </span>with +which<span class="w"> </span>to<span class="w"> </span>blow<span class="w"> </span>yourself<span class="w"> </span>up.<span class="w"> </span>Have<span class="w"> </span>a<span class="w"> </span>nice<span class="w"> </span>day! +Phase<span class="w"> </span><span class="m">1</span><span class="w"> </span>defused.<span class="w"> </span>How<span class="w"> </span>about<span class="w"> </span>the<span class="w"> </span>next<span class="w"> </span>one? +That<span class="err">'</span>s<span class="w"> </span>number<span class="w"> </span><span class="m">2</span>.<span class="w"> </span>Keep<span class="w"> </span>going! +Halfway<span class="w"> </span>there! +<span class="nb">test</span><span class="w"> </span>string + +Breakpoint<span class="w"> </span><span class="m">1</span>,<span class="w"> </span>0x00005555555557d3<span class="w"> </span><span class="k">in</span><span class="w"> </span>phase_4<span class="w"> </span><span class="o">()</span> +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span>disas<span class="w"> </span>phase_4 +Dump<span class="w"> </span>of<span class="w"> </span>assembler<span class="w"> </span>code<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="k">function</span><span class="w"> </span>phase_4: +<span class="o">=</span>><span class="w"> </span>0x00005555555557d3<span class="w"> </span><+0>:<span class="w"> </span>endbr64<span class="w"> </span> +<span class="w"> </span>0x00005555555557d7<span class="w"> </span><+4>:<span class="w"> </span>sub<span class="w"> </span><span class="nv">$0</span>x18,%rsp +<span class="w"> </span>0x00005555555557db<span class="w"> </span><+8>:<span class="w"> </span>lea<span class="w"> </span>0x8<span class="o">(</span>%rsp<span class="o">)</span>,%rcx +<span class="w"> </span>0x00005555555557e0<span class="w"> </span><+13>:<span class="w"> </span>lea<span class="w"> </span>0xc<span class="o">(</span>%rsp<span class="o">)</span>,%rdx +<span class="w"> </span>0x00005555555557e5<span class="w"> </span><+18>:<span class="w"> </span>lea<span class="w"> </span>0x1bba<span class="o">(</span>%rip<span class="o">)</span>,%rsi<span class="w"> </span><span class="c1"># 0x5555555573a6</span> +<span class="w"> </span>0x00005555555557ec<span class="w"> </span><+25>:<span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x0,%eax +<span class="w"> </span>0x00005555555557f1<span class="w"> </span><+30>:<span class="w"> </span>call<span class="w"> </span>0x5555555552e0<span class="w"> </span><__isoc99_sscanf@plt> +<span class="w"> </span>0x00005555555557f6<span class="w"> </span><+35>:<span class="w"> </span>cmp<span class="w"> </span><span class="nv">$0</span>x2,%eax +<span class="w"> </span>0x00005555555557f9<span class="w"> </span><+38>:<span class="w"> </span>jne<span class="w"> </span>0x555555555802<span class="w"> </span><phase_4+47> +<span class="w"> </span>0x00005555555557fb<span class="w"> </span><+40>:<span class="w"> </span>cmpl<span class="w"> </span><span class="nv">$0</span>xe,0xc<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>0x0000555555555800<span class="w"> </span><+45>:<span class="w"> </span>jbe<span class="w"> </span>0x555555555807<span class="w"> </span><phase_4+52> +<span class="w"> </span>0x0000555555555802<span class="w"> </span><+47>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span>0x0000555555555807<span class="w"> </span><+52>:<span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>xe,%edx +<span class="w"> </span>0x000055555555580c<span class="w"> </span><+57>:<span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x0,%esi +<span class="w"> </span>0x0000555555555811<span class="w"> </span><+62>:<span class="w"> </span>mov<span class="w"> </span>0xc<span class="o">(</span>%rsp<span class="o">)</span>,%edi +<span class="w"> </span>0x0000555555555815<span class="w"> </span><+66>:<span class="w"> </span>call<span class="w"> </span>0x555555555799<span class="w"> </span><func4> +<span class="w"> </span>0x000055555555581a<span class="w"> </span><+71>:<span class="w"> </span>cmp<span class="w"> </span><span class="nv">$0</span>x2,%eax +<span class="w"> </span>0x000055555555581d<span class="w"> </span><+74>:<span class="w"> </span>jne<span class="w"> </span>0x555555555826<span class="w"> </span><phase_4+83> +<span class="w"> </span>0x000055555555581f<span class="w"> </span><+76>:<span class="w"> </span>cmpl<span class="w"> </span><span class="nv">$0</span>x2,0x8<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>0x0000555555555824<span class="w"> </span><+81>:<span class="w"> </span>je<span class="w"> </span>0x55555555582b<span class="w"> </span><phase_4+88> +<span class="w"> </span>0x0000555555555826<span class="w"> </span><+83>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span>0x000055555555582b<span class="w"> </span><+88>:<span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x18,%rsp +<span class="w"> </span>0x000055555555582f<span class="w"> </span><+92>:<span class="w"> </span>ret<span class="w"> </span> +End<span class="w"> </span>of<span class="w"> </span>assembler<span class="w"> </span>dump. +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span> </code></pre> </div> <p>Again, <code>gdb</code> has marked the string being passed to <code>scanf</code></p> <div class="codehilite"> -<pre><span></span><code><span class="o">(</span>gdb<span class="o">)</span> x/1s 0x5555555573a6 -0x5555555573a6: <span class="s2">"%d %d"</span> +<pre><span></span><code><span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span>x/1s<span class="w"> </span>0x5555555573a6 +0x5555555573a6:<span class="w"> </span><span class="s2">"%d %d"</span> </code></pre> </div> -<p>Okay, so this time we are supposed to enter 2 numbers. - <div class="codehilite"> - <pre><span></span><code>0x00005555555557f6 <+35>: cmp <span class="nv">$0</span>x2,%eax - 0x00005555555557f9 <+38>: jne 0x555555555802 <phase_4+47> - </code></pre> - </div></p> +<p>Okay, so this time we are supposed to enter 2 numbers.</p> + +<div class="codehilite"> +<pre><span></span><code><span class="w"> </span>0x00005555555557f6<span class="w"> </span><+35>:<span class="w"> </span>cmp<span class="w"> </span><span class="nv">$0</span>x2,%eax +<span class="w"> </span>0x00005555555557f9<span class="w"> </span><+38>:<span class="w"> </span>jne<span class="w"> </span>0x555555555802<span class="w"> </span><phase_4+47> +</code></pre> +</div> -<p>Checks if there were 2 values read from calling <code>scanf</code>, if not -> jump to <code><phase_4+47></code> which calls <code><explode_bomb></code>. - <div class="codehilite"> - <pre><span></span><code>0x00005555555557fb <+40>: cmpl <span class="nv">$0</span>xe,0xc<span class="o">(</span>%rsp<span class="o">)</span> - 0x0000555555555800 <+45>: jbe 0x555555555807 <phase_4+52> - </code></pre> - </div></p> +<p>Checks if there were 2 values read from calling <code>scanf</code>, if not -> jump to <code><phase_4+47></code> which calls <code><explode_bomb></code>.</p> + +<div class="codehilite"> +<pre><span></span><code><span class="w"> </span>0x00005555555557fb<span class="w"> </span><+40>:<span class="w"> </span>cmpl<span class="w"> </span><span class="nv">$0</span>xe,0xc<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>0x0000555555555800<span class="w"> </span><+45>:<span class="w"> </span>jbe<span class="w"> </span>0x555555555807<span class="w"> </span><phase_4+52> +</code></pre> +</div> <p>Compare <code>0xe</code> (14 in Decimal) and value stored at <code>$rsp</code> + <code>0xc</code> bytes (Decimal 12). If this condition is met (<= 14), jump to <code><phase_4+52></code>. If not, then explode bomb.</p> <div class="codehilite"> <pre><span></span><code>... - 0x0000555555555807 <+52>: mov <span class="nv">$0</span>xe,%edx - 0x000055555555580c <+57>: mov <span class="nv">$0</span>x0,%esi - 0x0000555555555811 <+62>: mov 0xc<span class="o">(</span>%rsp<span class="o">)</span>,%edi - 0x0000555555555815 <+66>: call 0x555555555799 <func4> - 0x000055555555581a <+71>: cmp <span class="nv">$0</span>x2,%eax - 0x000055555555581d <+74>: jne 0x555555555826 <phase_4+83> - 0x000055555555581f <+76>: cmpl <span class="nv">$0</span>x2,0x8<span class="o">(</span>%rsp<span class="o">)</span> - 0x0000555555555824 <+81>: je 0x55555555582b <phase_4+88> - 0x0000555555555826 <+83>: call 0x555555555d4a <explode_bomb> +<span class="w"> </span>0x0000555555555807<span class="w"> </span><+52>:<span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>xe,%edx +<span class="w"> </span>0x000055555555580c<span class="w"> </span><+57>:<span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x0,%esi +<span class="w"> </span>0x0000555555555811<span class="w"> </span><+62>:<span class="w"> </span>mov<span class="w"> </span>0xc<span class="o">(</span>%rsp<span class="o">)</span>,%edi +<span class="w"> </span>0x0000555555555815<span class="w"> </span><+66>:<span class="w"> </span>call<span class="w"> </span>0x555555555799<span class="w"> </span><func4> +<span class="w"> </span>0x000055555555581a<span class="w"> </span><+71>:<span class="w"> </span>cmp<span class="w"> </span><span class="nv">$0</span>x2,%eax +<span class="w"> </span>0x000055555555581d<span class="w"> </span><+74>:<span class="w"> </span>jne<span class="w"> </span>0x555555555826<span class="w"> </span><phase_4+83> +<span class="w"> </span>0x000055555555581f<span class="w"> </span><+76>:<span class="w"> </span>cmpl<span class="w"> </span><span class="nv">$0</span>x2,0x8<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>0x0000555555555824<span class="w"> </span><+81>:<span class="w"> </span>je<span class="w"> </span>0x55555555582b<span class="w"> </span><phase_4+88> +<span class="w"> </span>0x0000555555555826<span class="w"> </span><+83>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> </code></pre> </div> @@ -3799,28 +3808,28 @@ End of assembler dump. <p>Let us look into <code>func4</code></p> <div class="codehilite"> -<pre><span></span><code><span class="o">(</span>gdb<span class="o">)</span> disas func4 -Dump of assembler code <span class="k">for</span> <span class="k">function</span> func4: - 0x0000555555555799 <+0>: endbr64 - 0x000055555555579d <+4>: sub <span class="nv">$0</span>x8,%rsp - 0x00005555555557a1 <+8>: mov %edx,%ecx - 0x00005555555557a3 <+10>: sub %esi,%ecx - 0x00005555555557a5 <+12>: shr %ecx - 0x00005555555557a7 <+14>: add %esi,%ecx - 0x00005555555557a9 <+16>: cmp %edi,%ecx - 0x00005555555557ab <+18>: ja 0x5555555557b9 <func4+32> - 0x00005555555557ad <+20>: mov <span class="nv">$0</span>x0,%eax - 0x00005555555557b2 <+25>: jb 0x5555555557c5 <func4+44> - 0x00005555555557b4 <+27>: add <span class="nv">$0</span>x8,%rsp - 0x00005555555557b8 <+31>: ret - 0x00005555555557b9 <+32>: lea -0x1<span class="o">(</span>%rcx<span class="o">)</span>,%edx - 0x00005555555557bc <+35>: call 0x555555555799 <func4> - 0x00005555555557c1 <+40>: add %eax,%eax - 0x00005555555557c3 <+42>: jmp 0x5555555557b4 <func4+27> - 0x00005555555557c5 <+44>: lea 0x1<span class="o">(</span>%rcx<span class="o">)</span>,%esi - 0x00005555555557c8 <+47>: call 0x555555555799 <func4> - 0x00005555555557cd <+52>: lea 0x1<span class="o">(</span>%rax,%rax,1<span class="o">)</span>,%eax - 0x00005555555557d1 <+56>: jmp 0x5555555557b4 <func4+27> +<pre><span></span><code><span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span>disas<span class="w"> </span>func4 +Dump<span class="w"> </span>of<span class="w"> </span>assembler<span class="w"> </span>code<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="k">function</span><span class="w"> </span>func4: +<span class="w"> </span>0x0000555555555799<span class="w"> </span><+0>:<span class="w"> </span>endbr64<span class="w"> </span> +<span class="w"> </span>0x000055555555579d<span class="w"> </span><+4>:<span class="w"> </span>sub<span class="w"> </span><span class="nv">$0</span>x8,%rsp +<span class="w"> </span>0x00005555555557a1<span class="w"> </span><+8>:<span class="w"> </span>mov<span class="w"> </span>%edx,%ecx +<span class="w"> </span>0x00005555555557a3<span class="w"> </span><+10>:<span class="w"> </span>sub<span class="w"> </span>%esi,%ecx +<span class="w"> </span>0x00005555555557a5<span class="w"> </span><+12>:<span class="w"> </span>shr<span class="w"> </span>%ecx +<span class="w"> </span>0x00005555555557a7<span class="w"> </span><+14>:<span class="w"> </span>add<span class="w"> </span>%esi,%ecx +<span class="w"> </span>0x00005555555557a9<span class="w"> </span><+16>:<span class="w"> </span>cmp<span class="w"> </span>%edi,%ecx +<span class="w"> </span>0x00005555555557ab<span class="w"> </span><+18>:<span class="w"> </span>ja<span class="w"> </span>0x5555555557b9<span class="w"> </span><func4+32> +<span class="w"> </span>0x00005555555557ad<span class="w"> </span><+20>:<span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x0,%eax +<span class="w"> </span>0x00005555555557b2<span class="w"> </span><+25>:<span class="w"> </span>jb<span class="w"> </span>0x5555555557c5<span class="w"> </span><func4+44> +<span class="w"> </span>0x00005555555557b4<span class="w"> </span><+27>:<span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x8,%rsp +<span class="w"> </span>0x00005555555557b8<span class="w"> </span><+31>:<span class="w"> </span>ret<span class="w"> </span> +<span class="w"> </span>0x00005555555557b9<span class="w"> </span><+32>:<span class="w"> </span>lea<span class="w"> </span>-0x1<span class="o">(</span>%rcx<span class="o">)</span>,%edx +<span class="w"> </span>0x00005555555557bc<span class="w"> </span><+35>:<span class="w"> </span>call<span class="w"> </span>0x555555555799<span class="w"> </span><func4> +<span class="w"> </span>0x00005555555557c1<span class="w"> </span><+40>:<span class="w"> </span>add<span class="w"> </span>%eax,%eax +<span class="w"> </span>0x00005555555557c3<span class="w"> </span><+42>:<span class="w"> </span>jmp<span class="w"> </span>0x5555555557b4<span class="w"> </span><func4+27> +<span class="w"> </span>0x00005555555557c5<span class="w"> </span><+44>:<span class="w"> </span>lea<span class="w"> </span>0x1<span class="o">(</span>%rcx<span class="o">)</span>,%esi +<span class="w"> </span>0x00005555555557c8<span class="w"> </span><+47>:<span class="w"> </span>call<span class="w"> </span>0x555555555799<span class="w"> </span><func4> +<span class="w"> </span>0x00005555555557cd<span class="w"> </span><+52>:<span class="w"> </span>lea<span class="w"> </span>0x1<span class="o">(</span>%rax,%rax,1<span class="o">)</span>,%eax +<span class="w"> </span>0x00005555555557d1<span class="w"> </span><+56>:<span class="w"> </span>jmp<span class="w"> </span>0x5555555557b4<span class="w"> </span><func4+27> </code></pre> </div> @@ -3830,25 +3839,25 @@ Dump of assembler code <span class="k">for</span> <span class="k">function</span <div class="codehilite"> <pre><span></span><code>endbr64 -sub <span class="nv">$0</span>x8,%rsp // subtract <span class="m">8</span> bytes from the stack pointer -mov %edx,%ecx // Move the value <span class="k">in</span> register %edx to %ecx -sub %esi,%ecx // Subtract the value <span class="k">in</span> %esi from %ecx -shr %ecx // Right <span class="nb">shift</span> the value <span class="k">in</span> %ecx by one bit <span class="o">(</span>dividing the value by <span class="m">2</span><span class="o">)</span> -add %esi,%ecx // Add the value <span class="k">in</span> %esi to %ecx -cmp %edi,%ecx // Compare -ja 0x5555555557b9 <func4+32> // If %ecx > %edi -> jump to instruction at offset +32 -mov <span class="nv">$0</span>x0,%eax // Move <span class="m">0</span> to %eax -jb 0x5555555557c5 <func4+44> // If %ecx < %edi -> jump to instruction at offset +44. -add <span class="nv">$0</span>x8,%rsp // add <span class="m">8</span> bytes to the stack pointer -ret // <span class="k">return</span> -lea -0x1<span class="o">(</span>%rcx<span class="o">)</span>,%edx // LEA of <span class="nv">$rxc</span> - <span class="m">1</span> into <span class="nv">$edx</span> -call 0x555555555799 <func4> // Call itself -add %eax,%eax // Double the value <span class="k">in</span> %eax -jmp 0x5555555557b4 <func4+27> // jump to the instruction at offset +27 -lea 0x1<span class="o">(</span>%rcx<span class="o">)</span>,%esi -call 0x555555555799 <func4> -lea 0x1<span class="o">(</span>%rax,%rax,1<span class="o">)</span>,%eax // LEA of %rax * <span class="m">2</span> + <span class="m">1</span> into <span class="nv">$eax</span> -jmp 0x5555555557b4 <func4+27> +sub<span class="w"> </span><span class="nv">$0</span>x8,%rsp<span class="w"> </span>//<span class="w"> </span>subtract<span class="w"> </span><span class="m">8</span><span class="w"> </span>bytes<span class="w"> </span>from<span class="w"> </span>the<span class="w"> </span>stack<span class="w"> </span>pointer +mov<span class="w"> </span>%edx,%ecx<span class="w"> </span>//<span class="w"> </span>Move<span class="w"> </span>the<span class="w"> </span>value<span class="w"> </span><span class="k">in</span><span class="w"> </span>register<span class="w"> </span>%edx<span class="w"> </span>to<span class="w"> </span>%ecx +sub<span class="w"> </span>%esi,%ecx<span class="w"> </span>//<span class="w"> </span>Subtract<span class="w"> </span>the<span class="w"> </span>value<span class="w"> </span><span class="k">in</span><span class="w"> </span>%esi<span class="w"> </span>from<span class="w"> </span>%ecx +shr<span class="w"> </span>%ecx<span class="w"> </span>//<span class="w"> </span>Right<span class="w"> </span><span class="nb">shift</span><span class="w"> </span>the<span class="w"> </span>value<span class="w"> </span><span class="k">in</span><span class="w"> </span>%ecx<span class="w"> </span>by<span class="w"> </span>one<span class="w"> </span>bit<span class="w"> </span><span class="o">(</span>dividing<span class="w"> </span>the<span class="w"> </span>value<span class="w"> </span>by<span class="w"> </span><span class="m">2</span><span class="o">)</span> +add<span class="w"> </span>%esi,%ecx<span class="w"> </span>//<span class="w"> </span>Add<span class="w"> </span>the<span class="w"> </span>value<span class="w"> </span><span class="k">in</span><span class="w"> </span>%esi<span class="w"> </span>to<span class="w"> </span>%ecx +cmp<span class="w"> </span>%edi,%ecx<span class="w"> </span>//<span class="w"> </span>Compare +ja<span class="w"> </span>0x5555555557b9<span class="w"> </span><func4+32><span class="w"> </span>//<span class="w"> </span>If<span class="w"> </span>%ecx<span class="w"> </span>><span class="w"> </span>%edi<span class="w"> </span>-><span class="w"> </span>jump<span class="w"> </span>to<span class="w"> </span>instruction<span class="w"> </span>at<span class="w"> </span>offset<span class="w"> </span>+32 +mov<span class="w"> </span><span class="nv">$0</span>x0,%eax<span class="w"> </span>//<span class="w"> </span>Move<span class="w"> </span><span class="m">0</span><span class="w"> </span>to<span class="w"> </span>%eax +jb<span class="w"> </span>0x5555555557c5<span class="w"> </span><func4+44><span class="w"> </span>//<span class="w"> </span>If<span class="w"> </span>%ecx<span class="w"> </span><<span class="w"> </span>%edi<span class="w"> </span>-><span class="w"> </span>jump<span class="w"> </span>to<span class="w"> </span>instruction<span class="w"> </span>at<span class="w"> </span>offset<span class="w"> </span>+44. +add<span class="w"> </span><span class="nv">$0</span>x8,%rsp<span class="w"> </span>//<span class="w"> </span>add<span class="w"> </span><span class="m">8</span><span class="w"> </span>bytes<span class="w"> </span>to<span class="w"> </span>the<span class="w"> </span>stack<span class="w"> </span>pointer +ret<span class="w"> </span>//<span class="w"> </span><span class="k">return</span> +lea<span class="w"> </span>-0x1<span class="o">(</span>%rcx<span class="o">)</span>,%edx<span class="w"> </span>//<span class="w"> </span>LEA<span class="w"> </span>of<span class="w"> </span><span class="nv">$rxc</span><span class="w"> </span>-<span class="w"> </span><span class="m">1</span><span class="w"> </span>into<span class="w"> </span><span class="nv">$edx</span> +call<span class="w"> </span>0x555555555799<span class="w"> </span><func4><span class="w"> </span>//<span class="w"> </span>Call<span class="w"> </span>itself +add<span class="w"> </span>%eax,%eax<span class="w"> </span>//<span class="w"> </span>Double<span class="w"> </span>the<span class="w"> </span>value<span class="w"> </span><span class="k">in</span><span class="w"> </span>%eax +jmp<span class="w"> </span>0x5555555557b4<span class="w"> </span><func4+27><span class="w"> </span>//<span class="w"> </span>jump<span class="w"> </span>to<span class="w"> </span>the<span class="w"> </span>instruction<span class="w"> </span>at<span class="w"> </span>offset<span class="w"> </span>+27 +lea<span class="w"> </span>0x1<span class="o">(</span>%rcx<span class="o">)</span>,%esi +call<span class="w"> </span>0x555555555799<span class="w"> </span><func4> +lea<span class="w"> </span>0x1<span class="o">(</span>%rax,%rax,1<span class="o">)</span>,%eax<span class="w"> </span>//<span class="w"> </span>LEA<span class="w"> </span>of<span class="w"> </span>%rax<span class="w"> </span>*<span class="w"> </span><span class="m">2</span><span class="w"> </span>+<span class="w"> </span><span class="m">1</span><span class="w"> </span>into<span class="w"> </span><span class="nv">$eax</span><span class="w"> </span> +jmp<span class="w"> </span>0x5555555557b4<span class="w"> </span><func4+27> </code></pre> </div> @@ -3875,79 +3884,80 @@ jmp 0x5555555557b4 <func4+27> <p>Okay, so we know that the number needed to be passed to <code>func4</code> is 5. But, what about the second digit?</p> -<p>If we go back to the code for <code><phase_4></code>, we can see that: - <div class="codehilite"> - <pre><span></span><code>0x000055555555581f <+76>: cmpl <span class="nv">$0</span>x2,0x8<span class="o">(</span>%rsp<span class="o">)</span> - 0x0000555555555824 <+81>: je 0x55555555582b <phase_4+88> - </code></pre> - </div></p> +<p>If we go back to the code for <code><phase_4></code>, we can see that:</p> + +<div class="codehilite"> +<pre><span></span><code><span class="w"> </span>0x000055555555581f<span class="w"> </span><+76>:<span class="w"> </span>cmpl<span class="w"> </span><span class="nv">$0</span>x2,0x8<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>0x0000555555555824<span class="w"> </span><+81>:<span class="w"> </span>je<span class="w"> </span>0x55555555582b<span class="w"> </span><phase_4+88> +</code></pre> +</div> <p>The value at <code>$rsp+8</code> should be equal to 2. So, let us try passing <code>5 2</code> as our input.</p> <div class="codehilite"> <pre><span></span><code>... -Phase <span class="m">1</span> defused. How about the next one? -That<span class="err">'</span>s number <span class="m">2</span>. Keep going! -Halfway there! -<span class="m">5</span> <span class="m">2</span> +Phase<span class="w"> </span><span class="m">1</span><span class="w"> </span>defused.<span class="w"> </span>How<span class="w"> </span>about<span class="w"> </span>the<span class="w"> </span>next<span class="w"> </span>one? +That<span class="err">'</span>s<span class="w"> </span>number<span class="w"> </span><span class="m">2</span>.<span class="w"> </span>Keep<span class="w"> </span>going! +Halfway<span class="w"> </span>there! +<span class="m">5</span><span class="w"> </span><span class="m">2</span> -Breakpoint <span class="m">1</span>, 0x00005555555557d3 <span class="k">in</span> phase_4 <span class="o">()</span> -<span class="o">(</span>gdb<span class="o">)</span> <span class="k">continue</span> +Breakpoint<span class="w"> </span><span class="m">1</span>,<span class="w"> </span>0x00005555555557d3<span class="w"> </span><span class="k">in</span><span class="w"> </span>phase_4<span class="w"> </span><span class="o">()</span> +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span><span class="k">continue</span> Continuing. -So you got that one. Try this one. +So<span class="w"> </span>you<span class="w"> </span>got<span class="w"> </span>that<span class="w"> </span>one.<span class="w"> </span>Try<span class="w"> </span>this<span class="w"> </span>one. </code></pre> </div> <h2>Phase 5</h2> <div class="codehilite"> -<pre><span></span><code>So you got that one. Try this one. -<span class="nb">test</span> string - -Breakpoint <span class="m">1</span>, 0x0000555555555830 <span class="k">in</span> phase_5 <span class="o">()</span> -<span class="o">(</span>gdb<span class="o">)</span> disas phase_5 -Dump of assembler code <span class="k">for</span> <span class="k">function</span> phase_5: -<span class="o">=</span>> 0x0000555555555830 <+0>: endbr64 - 0x0000555555555834 <+4>: push %rbx - 0x0000555555555835 <+5>: sub <span class="nv">$0</span>x10,%rsp - 0x0000555555555839 <+9>: mov %rdi,%rbx - 0x000055555555583c <+12>: call 0x555555555b10 <string_length> - 0x0000555555555841 <+17>: cmp <span class="nv">$0</span>x6,%eax - 0x0000555555555844 <+20>: jne 0x55555555588b <phase_5+91> - 0x0000555555555846 <+22>: mov <span class="nv">$0</span>x0,%eax - 0x000055555555584b <+27>: lea 0x199e<span class="o">(</span>%rip<span class="o">)</span>,%rcx <span class="c1"># 0x5555555571f0 <array.0></span> - 0x0000555555555852 <+34>: movzbl <span class="o">(</span>%rbx,%rax,1<span class="o">)</span>,%edx - 0x0000555555555856 <+38>: and <span class="nv">$0</span>xf,%edx - 0x0000555555555859 <+41>: movzbl <span class="o">(</span>%rcx,%rdx,1<span class="o">)</span>,%edx - 0x000055555555585d <+45>: mov %dl,0x9<span class="o">(</span>%rsp,%rax,1<span class="o">)</span> - 0x0000555555555861 <+49>: add <span class="nv">$0</span>x1,%rax - 0x0000555555555865 <+53>: cmp <span class="nv">$0</span>x6,%rax - 0x0000555555555869 <+57>: jne 0x555555555852 <phase_5+34> - 0x000055555555586b <+59>: movb <span class="nv">$0</span>x0,0xf<span class="o">(</span>%rsp<span class="o">)</span> - 0x0000555555555870 <+64>: lea 0x9<span class="o">(</span>%rsp<span class="o">)</span>,%rdi - 0x0000555555555875 <+69>: lea 0x1943<span class="o">(</span>%rip<span class="o">)</span>,%rsi <span class="c1"># 0x5555555571bf</span> - 0x000055555555587c <+76>: call 0x555555555b31 <strings_not_equal> - 0x0000555555555881 <+81>: <span class="nb">test</span> %eax,%eax - 0x0000555555555883 <+83>: jne 0x555555555892 <phase_5+98> - 0x0000555555555885 <+85>: add <span class="nv">$0</span>x10,%rsp - 0x0000555555555889 <+89>: pop %rbx - 0x000055555555588a <+90>: ret - 0x000055555555588b <+91>: call 0x555555555d4a <explode_bomb> - 0x0000555555555890 <+96>: jmp 0x555555555846 <phase_5+22> - 0x0000555555555892 <+98>: call 0x555555555d4a <explode_bomb> - 0x0000555555555897 <+103>: jmp 0x555555555885 <phase_5+85> -End of assembler dump. -<span class="o">(</span>gdb<span class="o">)</span> +<pre><span></span><code>So<span class="w"> </span>you<span class="w"> </span>got<span class="w"> </span>that<span class="w"> </span>one.<span class="w"> </span>Try<span class="w"> </span>this<span class="w"> </span>one. +<span class="nb">test</span><span class="w"> </span>string + +Breakpoint<span class="w"> </span><span class="m">1</span>,<span class="w"> </span>0x0000555555555830<span class="w"> </span><span class="k">in</span><span class="w"> </span>phase_5<span class="w"> </span><span class="o">()</span> +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span>disas<span class="w"> </span>phase_5 +Dump<span class="w"> </span>of<span class="w"> </span>assembler<span class="w"> </span>code<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="k">function</span><span class="w"> </span>phase_5: +<span class="o">=</span>><span class="w"> </span>0x0000555555555830<span class="w"> </span><+0>:<span class="w"> </span>endbr64<span class="w"> </span> +<span class="w"> </span>0x0000555555555834<span class="w"> </span><+4>:<span class="w"> </span>push<span class="w"> </span>%rbx +<span class="w"> </span>0x0000555555555835<span class="w"> </span><+5>:<span class="w"> </span>sub<span class="w"> </span><span class="nv">$0</span>x10,%rsp +<span class="w"> </span>0x0000555555555839<span class="w"> </span><+9>:<span class="w"> </span>mov<span class="w"> </span>%rdi,%rbx +<span class="w"> </span>0x000055555555583c<span class="w"> </span><+12>:<span class="w"> </span>call<span class="w"> </span>0x555555555b10<span class="w"> </span><string_length> +<span class="w"> </span>0x0000555555555841<span class="w"> </span><+17>:<span class="w"> </span>cmp<span class="w"> </span><span class="nv">$0</span>x6,%eax +<span class="w"> </span>0x0000555555555844<span class="w"> </span><+20>:<span class="w"> </span>jne<span class="w"> </span>0x55555555588b<span class="w"> </span><phase_5+91> +<span class="w"> </span>0x0000555555555846<span class="w"> </span><+22>:<span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x0,%eax +<span class="w"> </span>0x000055555555584b<span class="w"> </span><+27>:<span class="w"> </span>lea<span class="w"> </span>0x199e<span class="o">(</span>%rip<span class="o">)</span>,%rcx<span class="w"> </span><span class="c1"># 0x5555555571f0 <array.0></span> +<span class="w"> </span>0x0000555555555852<span class="w"> </span><+34>:<span class="w"> </span>movzbl<span class="w"> </span><span class="o">(</span>%rbx,%rax,1<span class="o">)</span>,%edx +<span class="w"> </span>0x0000555555555856<span class="w"> </span><+38>:<span class="w"> </span>and<span class="w"> </span><span class="nv">$0</span>xf,%edx +<span class="w"> </span>0x0000555555555859<span class="w"> </span><+41>:<span class="w"> </span>movzbl<span class="w"> </span><span class="o">(</span>%rcx,%rdx,1<span class="o">)</span>,%edx +<span class="w"> </span>0x000055555555585d<span class="w"> </span><+45>:<span class="w"> </span>mov<span class="w"> </span>%dl,0x9<span class="o">(</span>%rsp,%rax,1<span class="o">)</span> +<span class="w"> </span>0x0000555555555861<span class="w"> </span><+49>:<span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x1,%rax +<span class="w"> </span>0x0000555555555865<span class="w"> </span><+53>:<span class="w"> </span>cmp<span class="w"> </span><span class="nv">$0</span>x6,%rax +<span class="w"> </span>0x0000555555555869<span class="w"> </span><+57>:<span class="w"> </span>jne<span class="w"> </span>0x555555555852<span class="w"> </span><phase_5+34> +<span class="w"> </span>0x000055555555586b<span class="w"> </span><+59>:<span class="w"> </span>movb<span class="w"> </span><span class="nv">$0</span>x0,0xf<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>0x0000555555555870<span class="w"> </span><+64>:<span class="w"> </span>lea<span class="w"> </span>0x9<span class="o">(</span>%rsp<span class="o">)</span>,%rdi +<span class="w"> </span>0x0000555555555875<span class="w"> </span><+69>:<span class="w"> </span>lea<span class="w"> </span>0x1943<span class="o">(</span>%rip<span class="o">)</span>,%rsi<span class="w"> </span><span class="c1"># 0x5555555571bf</span> +<span class="w"> </span>0x000055555555587c<span class="w"> </span><+76>:<span class="w"> </span>call<span class="w"> </span>0x555555555b31<span class="w"> </span><strings_not_equal> +<span class="w"> </span>0x0000555555555881<span class="w"> </span><+81>:<span class="w"> </span><span class="nb">test</span><span class="w"> </span>%eax,%eax +<span class="w"> </span>0x0000555555555883<span class="w"> </span><+83>:<span class="w"> </span>jne<span class="w"> </span>0x555555555892<span class="w"> </span><phase_5+98> +<span class="w"> </span>0x0000555555555885<span class="w"> </span><+85>:<span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x10,%rsp +<span class="w"> </span>0x0000555555555889<span class="w"> </span><+89>:<span class="w"> </span>pop<span class="w"> </span>%rbx +<span class="w"> </span>0x000055555555588a<span class="w"> </span><+90>:<span class="w"> </span>ret<span class="w"> </span> +<span class="w"> </span>0x000055555555588b<span class="w"> </span><+91>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span>0x0000555555555890<span class="w"> </span><+96>:<span class="w"> </span>jmp<span class="w"> </span>0x555555555846<span class="w"> </span><phase_5+22> +<span class="w"> </span>0x0000555555555892<span class="w"> </span><+98>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span>0x0000555555555897<span class="w"> </span><+103>:<span class="w"> </span>jmp<span class="w"> </span>0x555555555885<span class="w"> </span><phase_5+85> +End<span class="w"> </span>of<span class="w"> </span>assembler<span class="w"> </span>dump. +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span> </code></pre> </div> <div class="codehilite"> <pre><span></span><code>... - 0x000055555555583c <+12>: call 0x555555555b10 <string_length> - 0x0000555555555841 <+17>: cmp <span class="nv">$0</span>x6,%eax - 0x0000555555555844 <+20>: jne 0x55555555588b <phase_5+91> +<span class="w"> </span>0x000055555555583c<span class="w"> </span><+12>:<span class="w"> </span>call<span class="w"> </span>0x555555555b10<span class="w"> </span><string_length> +<span class="w"> </span>0x0000555555555841<span class="w"> </span><+17>:<span class="w"> </span>cmp<span class="w"> </span><span class="nv">$0</span>x6,%eax +<span class="w"> </span>0x0000555555555844<span class="w"> </span><+20>:<span class="w"> </span>jne<span class="w"> </span>0x55555555588b<span class="w"> </span><phase_5+91> ... - 0x000055555555588b <+91>: call 0x555555555d4a <explode_bomb> +<span class="w"> </span>0x000055555555588b<span class="w"> </span><+91>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> ... </code></pre> </div> @@ -3975,11 +3985,11 @@ End of assembler dump. <p>We can check the reference string we need, which <code>gdb</code> has marked as <code># 0x5555555571bf</code>, and the lookup table marked as <code># 0x5555555571f0 <array.0></code></p> <div class="codehilite"> -<pre><span></span><code><span class="o">(</span>gdb<span class="o">)</span> x/s 0x5555555571bf -0x5555555571bf: <span class="s2">"bruins"</span> -<span class="o">(</span>gdb<span class="o">)</span> x/s 0x5555555571f0 -0x5555555571f0 <array.0>: <span class="s2">"maduiersnfotvbylSo you think you can stop the bomb with ctrl-c, do you?"</span> -<span class="o">(</span>gdb<span class="o">)</span> +<pre><span></span><code><span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span>x/s<span class="w"> </span>0x5555555571bf +0x5555555571bf:<span class="w"> </span><span class="s2">"bruins"</span> +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span>x/s<span class="w"> </span>0x5555555571f0 +0x5555555571f0<span class="w"> </span><array.0>:<span class="w"> </span><span class="s2">"maduiersnfotvbylSo you think you can stop the bomb with ctrl-c, do you?"</span> +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span> </code></pre> </div> @@ -4015,15 +4025,15 @@ s -> g <div class="codehilite"> <pre><span></span><code>... -That<span class="err">'</span>s number <span class="m">2</span>. Keep going! -Halfway there! -So you got that one. Try this one. +That<span class="err">'</span>s<span class="w"> </span>number<span class="w"> </span><span class="m">2</span>.<span class="w"> </span>Keep<span class="w"> </span>going! +Halfway<span class="w"> </span>there! +So<span class="w"> </span>you<span class="w"> </span>got<span class="w"> </span>that<span class="w"> </span>one.<span class="w"> </span>Try<span class="w"> </span>this<span class="w"> </span>one. mfcdhg -Breakpoint <span class="m">1</span>, 0x0000555555555830 <span class="k">in</span> phase_5 <span class="o">()</span> -<span class="o">(</span>gdb<span class="o">)</span> <span class="k">continue</span> +Breakpoint<span class="w"> </span><span class="m">1</span>,<span class="w"> </span>0x0000555555555830<span class="w"> </span><span class="k">in</span><span class="w"> </span>phase_5<span class="w"> </span><span class="o">()</span> +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span><span class="k">continue</span> Continuing. -Good work! On to the next... +Good<span class="w"> </span>work!<span class="w"> </span>On<span class="w"> </span>to<span class="w"> </span>the<span class="w"> </span>next... </code></pre> </div> @@ -4032,122 +4042,123 @@ Good work! On to the next... <h2>Phase 6</h2> <div class="codehilite"> -<pre><span></span><code>Good work! On to the next... -<span class="nb">test</span> string - -Breakpoint <span class="m">1</span>, 0x0000555555555899 <span class="k">in</span> phase_6 <span class="o">()</span> -<span class="o">(</span>gdb<span class="o">)</span> disas phase_6 -Dump of assembler code <span class="k">for</span> <span class="k">function</span> phase_6: -<span class="o">=</span>> 0x0000555555555899 <+0>: endbr64 - 0x000055555555589d <+4>: push %r15 - 0x000055555555589f <+6>: push %r14 - 0x00005555555558a1 <+8>: push %r13 - 0x00005555555558a3 <+10>: push %r12 - 0x00005555555558a5 <+12>: push %rbp - 0x00005555555558a6 <+13>: push %rbx - 0x00005555555558a7 <+14>: sub <span class="nv">$0</span>x68,%rsp - 0x00005555555558ab <+18>: lea 0x40<span class="o">(</span>%rsp<span class="o">)</span>,%rax - 0x00005555555558b0 <+23>: mov %rax,%r14 - 0x00005555555558b3 <+26>: mov %rax,0x8<span class="o">(</span>%rsp<span class="o">)</span> - 0x00005555555558b8 <+31>: mov %rax,%rsi - 0x00005555555558bb <+34>: call 0x555555555d97 <read_six_numbers> - 0x00005555555558c0 <+39>: mov %r14,%r12 - 0x00005555555558c3 <+42>: mov <span class="nv">$0</span>x1,%r15d - 0x00005555555558c9 <+48>: mov %r14,%r13 - 0x00005555555558cc <+51>: jmp 0x555555555997 <phase_6+254> - 0x00005555555558d1 <+56>: call 0x555555555d4a <explode_bomb> - 0x00005555555558d6 <+61>: jmp 0x5555555559a9 <phase_6+272> - 0x00005555555558db <+66>: add <span class="nv">$0</span>x1,%rbx - 0x00005555555558df <+70>: cmp <span class="nv">$0</span>x5,%ebx - 0x00005555555558e2 <+73>: jg 0x55555555598f <phase_6+246> - 0x00005555555558e8 <+79>: mov 0x0<span class="o">(</span>%r13,%rbx,4<span class="o">)</span>,%eax - 0x00005555555558ed <+84>: cmp %eax,0x0<span class="o">(</span>%rbp<span class="o">)</span> - 0x00005555555558f0 <+87>: jne 0x5555555558db <phase_6+66> - 0x00005555555558f2 <+89>: call 0x555555555d4a <explode_bomb> - 0x00005555555558f7 <+94>: jmp 0x5555555558db <phase_6+66> - 0x00005555555558f9 <+96>: mov 0x8<span class="o">(</span>%rsp<span class="o">)</span>,%rdx - 0x00005555555558fe <+101>: add <span class="nv">$0</span>x18,%rdx - 0x0000555555555902 <+105>: mov <span class="nv">$0</span>x7,%ecx - 0x0000555555555907 <+110>: mov %ecx,%eax - 0x0000555555555909 <+112>: sub <span class="o">(</span>%r12<span class="o">)</span>,%eax - 0x000055555555590d <+116>: mov %eax,<span class="o">(</span>%r12<span class="o">)</span> - 0x0000555555555911 <+120>: add <span class="nv">$0</span>x4,%r12 - 0x0000555555555915 <+124>: cmp %r12,%rdx - 0x0000555555555918 <+127>: jne 0x555555555907 <phase_6+110> - 0x000055555555591a <+129>: mov <span class="nv">$0</span>x0,%esi - 0x000055555555591f <+134>: mov 0x40<span class="o">(</span>%rsp,%rsi,4<span class="o">)</span>,%ecx - 0x0000555555555923 <+138>: mov <span class="nv">$0</span>x1,%eax - 0x0000555555555928 <+143>: lea 0x3d01<span class="o">(</span>%rip<span class="o">)</span>,%rdx <span class="c1"># 0x555555559630 <node1></span> ---Type <RET> <span class="k">for</span> more, q to quit, c to <span class="k">continue</span> without paging-- - 0x000055555555592f <+150>: cmp <span class="nv">$0</span>x1,%ecx - 0x0000555555555932 <+153>: jle 0x55555555593f <phase_6+166> - 0x0000555555555934 <+155>: mov 0x8<span class="o">(</span>%rdx<span class="o">)</span>,%rdx - 0x0000555555555938 <+159>: add <span class="nv">$0</span>x1,%eax - 0x000055555555593b <+162>: cmp %ecx,%eax - 0x000055555555593d <+164>: jne 0x555555555934 <phase_6+155> - 0x000055555555593f <+166>: mov %rdx,0x10<span class="o">(</span>%rsp,%rsi,8<span class="o">)</span> - 0x0000555555555944 <+171>: add <span class="nv">$0</span>x1,%rsi - 0x0000555555555948 <+175>: cmp <span class="nv">$0</span>x6,%rsi - 0x000055555555594c <+179>: jne 0x55555555591f <phase_6+134> - 0x000055555555594e <+181>: mov 0x10<span class="o">(</span>%rsp<span class="o">)</span>,%rbx - 0x0000555555555953 <+186>: mov 0x18<span class="o">(</span>%rsp<span class="o">)</span>,%rax - 0x0000555555555958 <+191>: mov %rax,0x8<span class="o">(</span>%rbx<span class="o">)</span> - 0x000055555555595c <+195>: mov 0x20<span class="o">(</span>%rsp<span class="o">)</span>,%rdx - 0x0000555555555961 <+200>: mov %rdx,0x8<span class="o">(</span>%rax<span class="o">)</span> - 0x0000555555555965 <+204>: mov 0x28<span class="o">(</span>%rsp<span class="o">)</span>,%rax - 0x000055555555596a <+209>: mov %rax,0x8<span class="o">(</span>%rdx<span class="o">)</span> - 0x000055555555596e <+213>: mov 0x30<span class="o">(</span>%rsp<span class="o">)</span>,%rdx - 0x0000555555555973 <+218>: mov %rdx,0x8<span class="o">(</span>%rax<span class="o">)</span> - 0x0000555555555977 <+222>: mov 0x38<span class="o">(</span>%rsp<span class="o">)</span>,%rax - 0x000055555555597c <+227>: mov %rax,0x8<span class="o">(</span>%rdx<span class="o">)</span> - 0x0000555555555980 <+231>: movq <span class="nv">$0</span>x0,0x8<span class="o">(</span>%rax<span class="o">)</span> - 0x0000555555555988 <+239>: mov <span class="nv">$0</span>x5,%ebp - 0x000055555555598d <+244>: jmp 0x5555555559c4 <phase_6+299> - 0x000055555555598f <+246>: add <span class="nv">$0</span>x1,%r15 - 0x0000555555555993 <+250>: add <span class="nv">$0</span>x4,%r14 - 0x0000555555555997 <+254>: mov %r14,%rbp - 0x000055555555599a <+257>: mov <span class="o">(</span>%r14<span class="o">)</span>,%eax - 0x000055555555599d <+260>: sub <span class="nv">$0</span>x1,%eax - 0x00005555555559a0 <+263>: cmp <span class="nv">$0</span>x5,%eax - 0x00005555555559a3 <+266>: ja 0x5555555558d1 <phase_6+56> - 0x00005555555559a9 <+272>: cmp <span class="nv">$0</span>x5,%r15d - 0x00005555555559ad <+276>: jg 0x5555555558f9 <phase_6+96> - 0x00005555555559b3 <+282>: mov %r15,%rbx - 0x00005555555559b6 <+285>: jmp 0x5555555558e8 <phase_6+79> - 0x00005555555559bb <+290>: mov 0x8<span class="o">(</span>%rbx<span class="o">)</span>,%rbx - 0x00005555555559bf <+294>: sub <span class="nv">$0</span>x1,%ebp - 0x00005555555559c2 <+297>: je 0x5555555559d5 <phase_6+316> - 0x00005555555559c4 <+299>: mov 0x8<span class="o">(</span>%rbx<span class="o">)</span>,%rax - 0x00005555555559c8 <+303>: mov <span class="o">(</span>%rax<span class="o">)</span>,%eax - 0x00005555555559ca <+305>: cmp %eax,<span class="o">(</span>%rbx<span class="o">)</span> ---Type <RET> <span class="k">for</span> more, q to quit, c to <span class="k">continue</span> without paging-- - 0x00005555555559cc <+307>: jge 0x5555555559bb <phase_6+290> - 0x00005555555559ce <+309>: call 0x555555555d4a <explode_bomb> - 0x00005555555559d3 <+314>: jmp 0x5555555559bb <phase_6+290> - 0x00005555555559d5 <+316>: add <span class="nv">$0</span>x68,%rsp - 0x00005555555559d9 <+320>: pop %rbx - 0x00005555555559da <+321>: pop %rbp - 0x00005555555559db <+322>: pop %r12 - 0x00005555555559dd <+324>: pop %r13 - 0x00005555555559df <+326>: pop %r14 - 0x00005555555559e1 <+328>: pop %r15 - 0x00005555555559e3 <+330>: ret -End of assembler dump. -<span class="o">(</span>gdb<span class="o">)</span> +<pre><span></span><code>Good<span class="w"> </span>work!<span class="w"> </span>On<span class="w"> </span>to<span class="w"> </span>the<span class="w"> </span>next... +<span class="nb">test</span><span class="w"> </span>string + +Breakpoint<span class="w"> </span><span class="m">1</span>,<span class="w"> </span>0x0000555555555899<span class="w"> </span><span class="k">in</span><span class="w"> </span>phase_6<span class="w"> </span><span class="o">()</span> +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span>disas<span class="w"> </span>phase_6 +Dump<span class="w"> </span>of<span class="w"> </span>assembler<span class="w"> </span>code<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="k">function</span><span class="w"> </span>phase_6: +<span class="o">=</span>><span class="w"> </span>0x0000555555555899<span class="w"> </span><+0>:<span class="w"> </span>endbr64<span class="w"> </span> +<span class="w"> </span>0x000055555555589d<span class="w"> </span><+4>:<span class="w"> </span>push<span class="w"> </span>%r15 +<span class="w"> </span>0x000055555555589f<span class="w"> </span><+6>:<span class="w"> </span>push<span class="w"> </span>%r14 +<span class="w"> </span>0x00005555555558a1<span class="w"> </span><+8>:<span class="w"> </span>push<span class="w"> </span>%r13 +<span class="w"> </span>0x00005555555558a3<span class="w"> </span><+10>:<span class="w"> </span>push<span class="w"> </span>%r12 +<span class="w"> </span>0x00005555555558a5<span class="w"> </span><+12>:<span class="w"> </span>push<span class="w"> </span>%rbp +<span class="w"> </span>0x00005555555558a6<span class="w"> </span><+13>:<span class="w"> </span>push<span class="w"> </span>%rbx +<span class="w"> </span>0x00005555555558a7<span class="w"> </span><+14>:<span class="w"> </span>sub<span class="w"> </span><span class="nv">$0</span>x68,%rsp +<span class="w"> </span>0x00005555555558ab<span class="w"> </span><+18>:<span class="w"> </span>lea<span class="w"> </span>0x40<span class="o">(</span>%rsp<span class="o">)</span>,%rax +<span class="w"> </span>0x00005555555558b0<span class="w"> </span><+23>:<span class="w"> </span>mov<span class="w"> </span>%rax,%r14 +<span class="w"> </span>0x00005555555558b3<span class="w"> </span><+26>:<span class="w"> </span>mov<span class="w"> </span>%rax,0x8<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>0x00005555555558b8<span class="w"> </span><+31>:<span class="w"> </span>mov<span class="w"> </span>%rax,%rsi +<span class="w"> </span>0x00005555555558bb<span class="w"> </span><+34>:<span class="w"> </span>call<span class="w"> </span>0x555555555d97<span class="w"> </span><read_six_numbers> +<span class="w"> </span>0x00005555555558c0<span class="w"> </span><+39>:<span class="w"> </span>mov<span class="w"> </span>%r14,%r12 +<span class="w"> </span>0x00005555555558c3<span class="w"> </span><+42>:<span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x1,%r15d +<span class="w"> </span>0x00005555555558c9<span class="w"> </span><+48>:<span class="w"> </span>mov<span class="w"> </span>%r14,%r13 +<span class="w"> </span>0x00005555555558cc<span class="w"> </span><+51>:<span class="w"> </span>jmp<span class="w"> </span>0x555555555997<span class="w"> </span><phase_6+254> +<span class="w"> </span>0x00005555555558d1<span class="w"> </span><+56>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span>0x00005555555558d6<span class="w"> </span><+61>:<span class="w"> </span>jmp<span class="w"> </span>0x5555555559a9<span class="w"> </span><phase_6+272> +<span class="w"> </span>0x00005555555558db<span class="w"> </span><+66>:<span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x1,%rbx +<span class="w"> </span>0x00005555555558df<span class="w"> </span><+70>:<span class="w"> </span>cmp<span class="w"> </span><span class="nv">$0</span>x5,%ebx +<span class="w"> </span>0x00005555555558e2<span class="w"> </span><+73>:<span class="w"> </span>jg<span class="w"> </span>0x55555555598f<span class="w"> </span><phase_6+246> +<span class="w"> </span>0x00005555555558e8<span class="w"> </span><+79>:<span class="w"> </span>mov<span class="w"> </span>0x0<span class="o">(</span>%r13,%rbx,4<span class="o">)</span>,%eax +<span class="w"> </span>0x00005555555558ed<span class="w"> </span><+84>:<span class="w"> </span>cmp<span class="w"> </span>%eax,0x0<span class="o">(</span>%rbp<span class="o">)</span> +<span class="w"> </span>0x00005555555558f0<span class="w"> </span><+87>:<span class="w"> </span>jne<span class="w"> </span>0x5555555558db<span class="w"> </span><phase_6+66> +<span class="w"> </span>0x00005555555558f2<span class="w"> </span><+89>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span>0x00005555555558f7<span class="w"> </span><+94>:<span class="w"> </span>jmp<span class="w"> </span>0x5555555558db<span class="w"> </span><phase_6+66> +<span class="w"> </span>0x00005555555558f9<span class="w"> </span><+96>:<span class="w"> </span>mov<span class="w"> </span>0x8<span class="o">(</span>%rsp<span class="o">)</span>,%rdx +<span class="w"> </span>0x00005555555558fe<span class="w"> </span><+101>:<span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x18,%rdx +<span class="w"> </span>0x0000555555555902<span class="w"> </span><+105>:<span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x7,%ecx +<span class="w"> </span>0x0000555555555907<span class="w"> </span><+110>:<span class="w"> </span>mov<span class="w"> </span>%ecx,%eax +<span class="w"> </span>0x0000555555555909<span class="w"> </span><+112>:<span class="w"> </span>sub<span class="w"> </span><span class="o">(</span>%r12<span class="o">)</span>,%eax +<span class="w"> </span>0x000055555555590d<span class="w"> </span><+116>:<span class="w"> </span>mov<span class="w"> </span>%eax,<span class="o">(</span>%r12<span class="o">)</span> +<span class="w"> </span>0x0000555555555911<span class="w"> </span><+120>:<span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x4,%r12 +<span class="w"> </span>0x0000555555555915<span class="w"> </span><+124>:<span class="w"> </span>cmp<span class="w"> </span>%r12,%rdx +<span class="w"> </span>0x0000555555555918<span class="w"> </span><+127>:<span class="w"> </span>jne<span class="w"> </span>0x555555555907<span class="w"> </span><phase_6+110> +<span class="w"> </span>0x000055555555591a<span class="w"> </span><+129>:<span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x0,%esi +<span class="w"> </span>0x000055555555591f<span class="w"> </span><+134>:<span class="w"> </span>mov<span class="w"> </span>0x40<span class="o">(</span>%rsp,%rsi,4<span class="o">)</span>,%ecx +<span class="w"> </span>0x0000555555555923<span class="w"> </span><+138>:<span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x1,%eax +<span class="w"> </span>0x0000555555555928<span class="w"> </span><+143>:<span class="w"> </span>lea<span class="w"> </span>0x3d01<span class="o">(</span>%rip<span class="o">)</span>,%rdx<span class="w"> </span><span class="c1"># 0x555555559630 <node1></span> +--Type<span class="w"> </span><RET><span class="w"> </span><span class="k">for</span><span class="w"> </span>more,<span class="w"> </span>q<span class="w"> </span>to<span class="w"> </span>quit,<span class="w"> </span>c<span class="w"> </span>to<span class="w"> </span><span class="k">continue</span><span class="w"> </span>without<span class="w"> </span>paging-- +<span class="w"> </span>0x000055555555592f<span class="w"> </span><+150>:<span class="w"> </span>cmp<span class="w"> </span><span class="nv">$0</span>x1,%ecx +<span class="w"> </span>0x0000555555555932<span class="w"> </span><+153>:<span class="w"> </span>jle<span class="w"> </span>0x55555555593f<span class="w"> </span><phase_6+166> +<span class="w"> </span>0x0000555555555934<span class="w"> </span><+155>:<span class="w"> </span>mov<span class="w"> </span>0x8<span class="o">(</span>%rdx<span class="o">)</span>,%rdx +<span class="w"> </span>0x0000555555555938<span class="w"> </span><+159>:<span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x1,%eax +<span class="w"> </span>0x000055555555593b<span class="w"> </span><+162>:<span class="w"> </span>cmp<span class="w"> </span>%ecx,%eax +<span class="w"> </span>0x000055555555593d<span class="w"> </span><+164>:<span class="w"> </span>jne<span class="w"> </span>0x555555555934<span class="w"> </span><phase_6+155> +<span class="w"> </span>0x000055555555593f<span class="w"> </span><+166>:<span class="w"> </span>mov<span class="w"> </span>%rdx,0x10<span class="o">(</span>%rsp,%rsi,8<span class="o">)</span> +<span class="w"> </span>0x0000555555555944<span class="w"> </span><+171>:<span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x1,%rsi +<span class="w"> </span>0x0000555555555948<span class="w"> </span><+175>:<span class="w"> </span>cmp<span class="w"> </span><span class="nv">$0</span>x6,%rsi +<span class="w"> </span>0x000055555555594c<span class="w"> </span><+179>:<span class="w"> </span>jne<span class="w"> </span>0x55555555591f<span class="w"> </span><phase_6+134> +<span class="w"> </span>0x000055555555594e<span class="w"> </span><+181>:<span class="w"> </span>mov<span class="w"> </span>0x10<span class="o">(</span>%rsp<span class="o">)</span>,%rbx +<span class="w"> </span>0x0000555555555953<span class="w"> </span><+186>:<span class="w"> </span>mov<span class="w"> </span>0x18<span class="o">(</span>%rsp<span class="o">)</span>,%rax +<span class="w"> </span>0x0000555555555958<span class="w"> </span><+191>:<span class="w"> </span>mov<span class="w"> </span>%rax,0x8<span class="o">(</span>%rbx<span class="o">)</span> +<span class="w"> </span>0x000055555555595c<span class="w"> </span><+195>:<span class="w"> </span>mov<span class="w"> </span>0x20<span class="o">(</span>%rsp<span class="o">)</span>,%rdx +<span class="w"> </span>0x0000555555555961<span class="w"> </span><+200>:<span class="w"> </span>mov<span class="w"> </span>%rdx,0x8<span class="o">(</span>%rax<span class="o">)</span> +<span class="w"> </span>0x0000555555555965<span class="w"> </span><+204>:<span class="w"> </span>mov<span class="w"> </span>0x28<span class="o">(</span>%rsp<span class="o">)</span>,%rax +<span class="w"> </span>0x000055555555596a<span class="w"> </span><+209>:<span class="w"> </span>mov<span class="w"> </span>%rax,0x8<span class="o">(</span>%rdx<span class="o">)</span> +<span class="w"> </span>0x000055555555596e<span class="w"> </span><+213>:<span class="w"> </span>mov<span class="w"> </span>0x30<span class="o">(</span>%rsp<span class="o">)</span>,%rdx +<span class="w"> </span>0x0000555555555973<span class="w"> </span><+218>:<span class="w"> </span>mov<span class="w"> </span>%rdx,0x8<span class="o">(</span>%rax<span class="o">)</span> +<span class="w"> </span>0x0000555555555977<span class="w"> </span><+222>:<span class="w"> </span>mov<span class="w"> </span>0x38<span class="o">(</span>%rsp<span class="o">)</span>,%rax +<span class="w"> </span>0x000055555555597c<span class="w"> </span><+227>:<span class="w"> </span>mov<span class="w"> </span>%rax,0x8<span class="o">(</span>%rdx<span class="o">)</span> +<span class="w"> </span>0x0000555555555980<span class="w"> </span><+231>:<span class="w"> </span>movq<span class="w"> </span><span class="nv">$0</span>x0,0x8<span class="o">(</span>%rax<span class="o">)</span> +<span class="w"> </span>0x0000555555555988<span class="w"> </span><+239>:<span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x5,%ebp +<span class="w"> </span>0x000055555555598d<span class="w"> </span><+244>:<span class="w"> </span>jmp<span class="w"> </span>0x5555555559c4<span class="w"> </span><phase_6+299> +<span class="w"> </span>0x000055555555598f<span class="w"> </span><+246>:<span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x1,%r15 +<span class="w"> </span>0x0000555555555993<span class="w"> </span><+250>:<span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x4,%r14 +<span class="w"> </span>0x0000555555555997<span class="w"> </span><+254>:<span class="w"> </span>mov<span class="w"> </span>%r14,%rbp +<span class="w"> </span>0x000055555555599a<span class="w"> </span><+257>:<span class="w"> </span>mov<span class="w"> </span><span class="o">(</span>%r14<span class="o">)</span>,%eax +<span class="w"> </span>0x000055555555599d<span class="w"> </span><+260>:<span class="w"> </span>sub<span class="w"> </span><span class="nv">$0</span>x1,%eax +<span class="w"> </span>0x00005555555559a0<span class="w"> </span><+263>:<span class="w"> </span>cmp<span class="w"> </span><span class="nv">$0</span>x5,%eax +<span class="w"> </span>0x00005555555559a3<span class="w"> </span><+266>:<span class="w"> </span>ja<span class="w"> </span>0x5555555558d1<span class="w"> </span><phase_6+56> +<span class="w"> </span>0x00005555555559a9<span class="w"> </span><+272>:<span class="w"> </span>cmp<span class="w"> </span><span class="nv">$0</span>x5,%r15d +<span class="w"> </span>0x00005555555559ad<span class="w"> </span><+276>:<span class="w"> </span>jg<span class="w"> </span>0x5555555558f9<span class="w"> </span><phase_6+96> +<span class="w"> </span>0x00005555555559b3<span class="w"> </span><+282>:<span class="w"> </span>mov<span class="w"> </span>%r15,%rbx +<span class="w"> </span>0x00005555555559b6<span class="w"> </span><+285>:<span class="w"> </span>jmp<span class="w"> </span>0x5555555558e8<span class="w"> </span><phase_6+79> +<span class="w"> </span>0x00005555555559bb<span class="w"> </span><+290>:<span class="w"> </span>mov<span class="w"> </span>0x8<span class="o">(</span>%rbx<span class="o">)</span>,%rbx +<span class="w"> </span>0x00005555555559bf<span class="w"> </span><+294>:<span class="w"> </span>sub<span class="w"> </span><span class="nv">$0</span>x1,%ebp +<span class="w"> </span>0x00005555555559c2<span class="w"> </span><+297>:<span class="w"> </span>je<span class="w"> </span>0x5555555559d5<span class="w"> </span><phase_6+316> +<span class="w"> </span>0x00005555555559c4<span class="w"> </span><+299>:<span class="w"> </span>mov<span class="w"> </span>0x8<span class="o">(</span>%rbx<span class="o">)</span>,%rax +<span class="w"> </span>0x00005555555559c8<span class="w"> </span><+303>:<span class="w"> </span>mov<span class="w"> </span><span class="o">(</span>%rax<span class="o">)</span>,%eax +<span class="w"> </span>0x00005555555559ca<span class="w"> </span><+305>:<span class="w"> </span>cmp<span class="w"> </span>%eax,<span class="o">(</span>%rbx<span class="o">)</span> +--Type<span class="w"> </span><RET><span class="w"> </span><span class="k">for</span><span class="w"> </span>more,<span class="w"> </span>q<span class="w"> </span>to<span class="w"> </span>quit,<span class="w"> </span>c<span class="w"> </span>to<span class="w"> </span><span class="k">continue</span><span class="w"> </span>without<span class="w"> </span>paging-- +<span class="w"> </span>0x00005555555559cc<span class="w"> </span><+307>:<span class="w"> </span>jge<span class="w"> </span>0x5555555559bb<span class="w"> </span><phase_6+290> +<span class="w"> </span>0x00005555555559ce<span class="w"> </span><+309>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span>0x00005555555559d3<span class="w"> </span><+314>:<span class="w"> </span>jmp<span class="w"> </span>0x5555555559bb<span class="w"> </span><phase_6+290> +<span class="w"> </span>0x00005555555559d5<span class="w"> </span><+316>:<span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x68,%rsp +<span class="w"> </span>0x00005555555559d9<span class="w"> </span><+320>:<span class="w"> </span>pop<span class="w"> </span>%rbx +<span class="w"> </span>0x00005555555559da<span class="w"> </span><+321>:<span class="w"> </span>pop<span class="w"> </span>%rbp +<span class="w"> </span>0x00005555555559db<span class="w"> </span><+322>:<span class="w"> </span>pop<span class="w"> </span>%r12 +<span class="w"> </span>0x00005555555559dd<span class="w"> </span><+324>:<span class="w"> </span>pop<span class="w"> </span>%r13 +<span class="w"> </span>0x00005555555559df<span class="w"> </span><+326>:<span class="w"> </span>pop<span class="w"> </span>%r14 +<span class="w"> </span>0x00005555555559e1<span class="w"> </span><+328>:<span class="w"> </span>pop<span class="w"> </span>%r15 +<span class="w"> </span>0x00005555555559e3<span class="w"> </span><+330>:<span class="w"> </span>ret<span class="w"> </span> +End<span class="w"> </span>of<span class="w"> </span>assembler<span class="w"> </span>dump. +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span> </code></pre> </div> <p>Again, we see the familiar <code>read_six_digits</code> function.</p> -<p>Let us analyse this function in chunks: - <div class="codehilite"> - <pre><span></span><code>0x00005555555558bb <+34>: call 0x555555555d97 <read<em>six</em>numbers> - 0x00005555555558c0 <+39>: mov %r14,%r12 - 0x00005555555558c3 <+42>: mov <span class="nv">$0</span>x1,%r15d - 0x00005555555558c9 <+48>: mov %r14,%r13 - 0x00005555555558cc <+51>: jmp 0x555555555997 <phase_6+254> - </code></pre> - </div></p> +<p>Let us analyse this function in chunks:</p> + +<div class="codehilite"> +<pre><span></span><code><span class="w"> </span>0x00005555555558bb<span class="w"> </span><+34>:<span class="w"> </span>call<span class="w"> </span>0x555555555d97<span class="w"> </span><read_six_numbers> +<span class="w"> </span>0x00005555555558c0<span class="w"> </span><+39>:<span class="w"> </span>mov<span class="w"> </span>%r14,%r12 +<span class="w"> </span>0x00005555555558c3<span class="w"> </span><+42>:<span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x1,%r15d +<span class="w"> </span>0x00005555555558c9<span class="w"> </span><+48>:<span class="w"> </span>mov<span class="w"> </span>%r14,%r13 +<span class="w"> </span>0x00005555555558cc<span class="w"> </span><+51>:<span class="w"> </span>jmp<span class="w"> </span>0x555555555997<span class="w"> </span><phase_6+254> +</code></pre> +</div> <ol> <li>Read six numbers</li> @@ -4155,17 +4166,20 @@ End of assembler dump. 2.1. <code>mov %r14,%r12</code>: <code>%r14</code> should be pointing to the location of the stack where the numbers were read into. This address is copied onto <code>%r12</code> 2.2. <code>mov $0x1,%r15d</code>: The value <code>1</code> is moved into <code>%r15</code> register (probably acting like a counter) 2.3. <code>mov %r14,%r13</code>: The value is also copied to <code>%r13</code></li> -<li><p>Jump to start of loop:</p> +<li>Jump to start of loop:</li> +</ol> <div class="codehilite"> -<pre><span></span><code>0x0000555555555997 <+254>: mov %r14,%rbp -0x000055555555599a <+257>: mov <span class="o">(</span>%r14<span class="o">)</span>,%eax -0x000055555555599d <+260>: sub <span class="nv">$0</span>x1,%eax -0x00005555555559a0 <+263>: cmp <span class="nv">$0</span>x5,%eax -0x00005555555559a3 <+266>: ja 0x5555555558d1 <phase_6+56> +<pre><span></span><code><span class="w"> </span>0x0000555555555997<span class="w"> </span><+254>:<span class="w"> </span>mov<span class="w"> </span>%r14,%rbp +<span class="w"> </span>0x000055555555599a<span class="w"> </span><+257>:<span class="w"> </span>mov<span class="w"> </span><span class="o">(</span>%r14<span class="o">)</span>,%eax +<span class="w"> </span>0x000055555555599d<span class="w"> </span><+260>:<span class="w"> </span>sub<span class="w"> </span><span class="nv">$0</span>x1,%eax +<span class="w"> </span>0x00005555555559a0<span class="w"> </span><+263>:<span class="w"> </span>cmp<span class="w"> </span><span class="nv">$0</span>x5,%eax +<span class="w"> </span>0x00005555555559a3<span class="w"> </span><+266>:<span class="w"> </span>ja<span class="w"> </span>0x5555555558d1<span class="w"> </span><phase_6+56> </code></pre> -</div></li> -<li><p>Initialise register and point to first number in sequence</p></li> +</div> + +<ol> +<li>Initialise register and point to first number in sequence</li> <li>Adjust number(s): 2.1. <code>mov (%r14),%eax</code> -> load the current number in the sequence 2.2. <code>sub $0x1,%eax</code> -> decrement number by 1</li> @@ -4174,40 +4188,44 @@ End of assembler dump. 3.2. <code>ja 0x5555555558d1 <phase_6+56></code>: jump if given value is > 5 or < 0</li> </ol> -<p>=> All numbers should be between 1 and 6. - <div class="codehilite"> - <pre><span></span><code>0x00005555555559a9 <+272>: cmp <span class="nv">$0</span>x5,%r15d - 0x00005555555559ad <+276>: jg 0x5555555558f9 <phase_6+96> - </code></pre> - </div></p> - -<p>This checks if the value stored in <code>%r15</code> is > 5, if it is then it jumps somewhere else. This validates our assumption that <code>%r15</code> is acting as a counter. - <div class="codehilite"> - <pre><span></span><code>0x00005555555559b3 <+282>: mov %r15,%rbx - 0x00005555555559b6 <+285>: jmp 0x5555555558e8 <phase_6+79> - </code></pre> - </div></p> - -<p>Let us jump to +79 - <div class="codehilite"> - <pre><span></span><code>0x00005555555558e8 <+79>: mov 0x0<span class="o">(</span>%r13,%rbx,4<span class="o">)</span>,%eax - 0x00005555555558ed <+84>: cmp %eax,0x0<span class="o">(</span>%rbp<span class="o">)</span> - 0x00005555555558f0 <+87>: jne 0x5555555558db <phase<em>6+66> - 0x00005555555558f2 <+89>: call 0x555555555d4a <explode</em>bomb> - 0x00005555555558f7 <+94>: jmp 0x5555555558db <phase_6+66> - </code></pre> - </div></p> - -<p>This section deals with checking if all the numbers in the sequence are unique or not. Thus, we need to ensure out 6 digits are unique - <div class="codehilite"> - <pre><span></span><code>0x00005555555558db <+66>: add <span class="nv">$0</span>x1,%rbx // Increments by <span class="m">1</span> - 0x00005555555558df <+70>: cmp <span class="nv">$0</span>x5,%ebx - 0x00005555555558e2 <+73>: jg 0x55555555598f <phase<em>6+246> // Jump <span class="k">if</span> > <span class="m">5</span> <span class="o">(</span>Loop iterations are <span class="nb">complete</span><span class="o">)</span> - 0x00005555555558e8 <+79>: mov 0x0<span class="o">(</span>%r13,%rbx,4<span class="o">)</span>,%eax - 0x00005555555558ed <+84>: cmp %eax,0x0<span class="o">(</span>%rbp<span class="o">)</span> - 0x00005555555558f0 <+87>: jne 0x5555555558db <phase</em>6+66> // Again, check <span class="k">if</span> the number being seen is unique - </code></pre> - </div></p> +<p>=> All numbers should be between 1 and 6.</p> + +<div class="codehilite"> +<pre><span></span><code><span class="w"> </span>0x00005555555559a9<span class="w"> </span><+272>:<span class="w"> </span>cmp<span class="w"> </span><span class="nv">$0</span>x5,%r15d +<span class="w"> </span>0x00005555555559ad<span class="w"> </span><+276>:<span class="w"> </span>jg<span class="w"> </span>0x5555555558f9<span class="w"> </span><phase_6+96> +</code></pre> +</div> + +<p>This checks if the value stored in <code>%r15</code> is > 5, if it is then it jumps somewhere else. This validates our assumption that <code>%r15</code> is acting as a counter.</p> + +<div class="codehilite"> +<pre><span></span><code><span class="w"> </span>0x00005555555559b3<span class="w"> </span><+282>:<span class="w"> </span>mov<span class="w"> </span>%r15,%rbx +<span class="w"> </span>0x00005555555559b6<span class="w"> </span><+285>:<span class="w"> </span>jmp<span class="w"> </span>0x5555555558e8<span class="w"> </span><phase_6+79> +</code></pre> +</div> + +<p>Let us jump to +79</p> + +<div class="codehilite"> +<pre><span></span><code><span class="w"> </span>0x00005555555558e8<span class="w"> </span><+79>:<span class="w"> </span>mov<span class="w"> </span>0x0<span class="o">(</span>%r13,%rbx,4<span class="o">)</span>,%eax +<span class="w"> </span>0x00005555555558ed<span class="w"> </span><+84>:<span class="w"> </span>cmp<span class="w"> </span>%eax,0x0<span class="o">(</span>%rbp<span class="o">)</span> +<span class="w"> </span>0x00005555555558f0<span class="w"> </span><+87>:<span class="w"> </span>jne<span class="w"> </span>0x5555555558db<span class="w"> </span><phase_6+66> +<span class="w"> </span>0x00005555555558f2<span class="w"> </span><+89>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span>0x00005555555558f7<span class="w"> </span><+94>:<span class="w"> </span>jmp<span class="w"> </span>0x5555555558db<span class="w"> </span><phase_6+66> +</code></pre> +</div> + +<p>This section deals with checking if all the numbers in the sequence are unique or not. Thus, we need to ensure out 6 digits are unique</p> + +<div class="codehilite"> +<pre><span></span><code><span class="w"> </span>0x00005555555558db<span class="w"> </span><+66>:<span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x1,%rbx<span class="w"> </span>//<span class="w"> </span>Increments<span class="w"> </span>by<span class="w"> </span><span class="m">1</span> +<span class="w"> </span>0x00005555555558df<span class="w"> </span><+70>:<span class="w"> </span>cmp<span class="w"> </span><span class="nv">$0</span>x5,%ebx<span class="w"> </span> +<span class="w"> </span>0x00005555555558e2<span class="w"> </span><+73>:<span class="w"> </span>jg<span class="w"> </span>0x55555555598f<span class="w"> </span><phase_6+246><span class="w"> </span>//<span class="w"> </span>Jump<span class="w"> </span><span class="k">if</span><span class="w"> </span>><span class="w"> </span><span class="m">5</span><span class="w"> </span><span class="o">(</span>Loop<span class="w"> </span>iterations<span class="w"> </span>are<span class="w"> </span><span class="nb">complete</span><span class="o">)</span> +<span class="w"> </span>0x00005555555558e8<span class="w"> </span><+79>:<span class="w"> </span>mov<span class="w"> </span>0x0<span class="o">(</span>%r13,%rbx,4<span class="o">)</span>,%eax<span class="w"> </span> +<span class="w"> </span>0x00005555555558ed<span class="w"> </span><+84>:<span class="w"> </span>cmp<span class="w"> </span>%eax,0x0<span class="o">(</span>%rbp<span class="o">)</span> +<span class="w"> </span>0x00005555555558f0<span class="w"> </span><+87>:<span class="w"> </span>jne<span class="w"> </span>0x5555555558db<span class="w"> </span><phase_6+66><span class="w"> </span>//<span class="w"> </span>Again,<span class="w"> </span>check<span class="w"> </span><span class="k">if</span><span class="w"> </span>the<span class="w"> </span>number<span class="w"> </span>being<span class="w"> </span>seen<span class="w"> </span>is<span class="w"> </span>unique +</code></pre> +</div> <p>Now we know that the numbers are unique, between 1-6 (inclusive).</p> @@ -4218,36 +4236,36 @@ End of assembler dump. <p>Let us try to figure out what <code>0x0000555555555928 <+143>: lea 0x3d01(%rip),%rdx # 0x555555559630 <node1></code> is:</p> <div class="codehilite"> -<pre><span></span><code><span class="o">(</span>gdb<span class="o">)</span> x/30wx 0x555555559630 -0x555555559630 <node1>: 0x000000d9 0x00000001 0x55559640 0x00005555 -0x555555559640 <node2>: 0x000003ab 0x00000002 0x55559650 0x00005555 -0x555555559650 <node3>: 0x0000014f 0x00000003 0x55559660 0x00005555 -0x555555559660 <node4>: 0x000000a1 0x00000004 0x55559670 0x00005555 -0x555555559670 <node5>: 0x000001b3 0x00000005 0x55559120 0x00005555 -0x555555559680 <host_table>: 0x555573f5 0x00005555 0x5555740f 0x00005555 -0x555555559690 <host_table+16>: 0x55557429 0x00005555 0x00000000 0x00000000 -0x5555555596a0 <host_table+32>: 0x00000000 0x00000000 -<span class="o">(</span>gdb<span class="o">)</span> x/30wx 0x555555559120 -0x555555559120 <node6>: 0x000002da 0x00000006 0x00000000 0x00000000 -0x555555559130: 0x00000000 0x00000000 0x00000000 0x00000000 -0x555555559140 <userid>: 0x61767861 0x38383535 0x00000000 0x00000000 -0x555555559150 <userid+16>: 0x00000000 0x00000000 0x00000000 0x00000000 -0x555555559160 <userid+32>: 0x00000000 0x00000000 0x00000000 0x00000000 -0x555555559170 <userid+48>: 0x00000000 0x00000000 0x00000000 0x00000000 -0x555555559180 <userid+64>: 0x00000000 0x00000000 0x00000000 0x00000000 -0x555555559190 <userid+80>: 0x00000000 0x00000000 -<span class="o">(</span>gdb<span class="o">)</span> +<pre><span></span><code><span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span>x/30wx<span class="w"> </span>0x555555559630 +0x555555559630<span class="w"> </span><node1>:<span class="w"> </span>0x000000d9<span class="w"> </span>0x00000001<span class="w"> </span>0x55559640<span class="w"> </span>0x00005555 +0x555555559640<span class="w"> </span><node2>:<span class="w"> </span>0x000003ab<span class="w"> </span>0x00000002<span class="w"> </span>0x55559650<span class="w"> </span>0x00005555 +0x555555559650<span class="w"> </span><node3>:<span class="w"> </span>0x0000014f<span class="w"> </span>0x00000003<span class="w"> </span>0x55559660<span class="w"> </span>0x00005555 +0x555555559660<span class="w"> </span><node4>:<span class="w"> </span>0x000000a1<span class="w"> </span>0x00000004<span class="w"> </span>0x55559670<span class="w"> </span>0x00005555 +0x555555559670<span class="w"> </span><node5>:<span class="w"> </span>0x000001b3<span class="w"> </span>0x00000005<span class="w"> </span>0x55559120<span class="w"> </span>0x00005555 +0x555555559680<span class="w"> </span><host_table>:<span class="w"> </span>0x555573f5<span class="w"> </span>0x00005555<span class="w"> </span>0x5555740f<span class="w"> </span>0x00005555 +0x555555559690<span class="w"> </span><host_table+16>:<span class="w"> </span>0x55557429<span class="w"> </span>0x00005555<span class="w"> </span>0x00000000<span class="w"> </span>0x00000000 +0x5555555596a0<span class="w"> </span><host_table+32>:<span class="w"> </span>0x00000000<span class="w"> </span>0x00000000 +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span>x/30wx<span class="w"> </span>0x555555559120 +0x555555559120<span class="w"> </span><node6>:<span class="w"> </span>0x000002da<span class="w"> </span>0x00000006<span class="w"> </span>0x00000000<span class="w"> </span>0x00000000 +0x555555559130:<span class="w"> </span>0x00000000<span class="w"> </span>0x00000000<span class="w"> </span>0x00000000<span class="w"> </span>0x00000000 +0x555555559140<span class="w"> </span><userid>:<span class="w"> </span>0x61767861<span class="w"> </span>0x38383535<span class="w"> </span>0x00000000<span class="w"> </span>0x00000000 +0x555555559150<span class="w"> </span><userid+16>:<span class="w"> </span>0x00000000<span class="w"> </span>0x00000000<span class="w"> </span>0x00000000<span class="w"> </span>0x00000000 +0x555555559160<span class="w"> </span><userid+32>:<span class="w"> </span>0x00000000<span class="w"> </span>0x00000000<span class="w"> </span>0x00000000<span class="w"> </span>0x00000000 +0x555555559170<span class="w"> </span><userid+48>:<span class="w"> </span>0x00000000<span class="w"> </span>0x00000000<span class="w"> </span>0x00000000<span class="w"> </span>0x00000000 +0x555555559180<span class="w"> </span><userid+64>:<span class="w"> </span>0x00000000<span class="w"> </span>0x00000000<span class="w"> </span>0x00000000<span class="w"> </span>0x00000000 +0x555555559190<span class="w"> </span><userid+80>:<span class="w"> </span>0x00000000<span class="w"> </span>0x00000000 +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span> </code></pre> </div> <p>It appears that this is a linked list. With roughly the following structure:</p> <div class="codehilite"> -<pre><span></span><code><span class="k">struct</span><span class="w"> </span><span class="nc">node</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">value</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">index</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="k">struct</span><span class="w"> </span><span class="nc">node</span><span class="w"> </span><span class="o">*</span><span class="n">next</span><span class="p">;</span><span class="w"></span> -<span class="p">};</span><span class="w"></span> +<pre><span></span><code><span class="k">struct</span><span class="w"> </span><span class="nc">node</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">value</span><span class="p">;</span> +<span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">index</span><span class="p">;</span> +<span class="w"> </span><span class="k">struct</span><span class="w"> </span><span class="nc">node</span><span class="w"> </span><span class="o">*</span><span class="n">next</span><span class="p">;</span> +<span class="p">};</span> </code></pre> </div> @@ -4315,14 +4333,14 @@ Your instructor has been notified and will verify your solution. <h2>Dependencies</h2> <div class="codehilite"> -<pre><span></span><code>sudo apt update <span class="o">&&</span> sudo apt install certbot -y +<pre><span></span><code>sudo<span class="w"> </span>apt<span class="w"> </span>update<span class="w"> </span><span class="o">&&</span><span class="w"> </span>sudo<span class="w"> </span>apt<span class="w"> </span>install<span class="w"> </span>certbot<span class="w"> </span>-y </code></pre> </div> <h2>Get the Certificate</h2> <div class="codehilite"> -<pre><span></span><code>sudo certbot certonly --manual --preferred-challenges dns-01 --email senpai@email.com -d mydomain.duckdns.org +<pre><span></span><code>sudo<span class="w"> </span>certbot<span class="w"> </span>certonly<span class="w"> </span>--manual<span class="w"> </span>--preferred-challenges<span class="w"> </span>dns-01<span class="w"> </span>--email<span class="w"> </span>senpai@email.com<span class="w"> </span>-d<span class="w"> </span>mydomain.duckdns.org </code></pre> </div> @@ -4338,25 +4356,25 @@ Your instructor has been notified and will verify your solution. <p>You can check if the TXT records have been updated by using the <code>dig</code> command:</p> <div class="codehilite"> -<pre><span></span><code>dig navanspi.duckdns.org TXT -<span class="p">;</span> <<>> DiG <span class="m">9</span>.16.1-Ubuntu <<>> navanspi.duckdns.org TXT -<span class="p">;;</span> global options: +cmd -<span class="p">;;</span> Got answer: -<span class="p">;;</span> ->>HEADER<span class="s"><<- opco</span>de: QUERY, status: NOERROR, id: <span class="m">27592</span> -<span class="p">;;</span> flags: qr rd ra<span class="p">;</span> QUERY: <span class="m">1</span>, ANSWER: <span class="m">1</span>, AUTHORITY: <span class="m">0</span>, ADDITIONAL: <span class="m">1</span> +<pre><span></span><code>dig<span class="w"> </span>navanspi.duckdns.org<span class="w"> </span>TXT +<span class="p">;</span><span class="w"> </span><<>><span class="w"> </span>DiG<span class="w"> </span><span class="m">9</span>.16.1-Ubuntu<span class="w"> </span><<>><span class="w"> </span>navanspi.duckdns.org<span class="w"> </span>TXT +<span class="p">;;</span><span class="w"> </span>global<span class="w"> </span>options:<span class="w"> </span>+cmd +<span class="p">;;</span><span class="w"> </span>Got<span class="w"> </span>answer: +<span class="p">;;</span><span class="w"> </span>->>HEADER<span class="s"><<- opco</span>de:<span class="w"> </span>QUERY,<span class="w"> </span>status:<span class="w"> </span>NOERROR,<span class="w"> </span>id:<span class="w"> </span><span class="m">27592</span> +<span class="p">;;</span><span class="w"> </span>flags:<span class="w"> </span>qr<span class="w"> </span>rd<span class="w"> </span>ra<span class="p">;</span><span class="w"> </span>QUERY:<span class="w"> </span><span class="m">1</span>,<span class="w"> </span>ANSWER:<span class="w"> </span><span class="m">1</span>,<span class="w"> </span>AUTHORITY:<span class="w"> </span><span class="m">0</span>,<span class="w"> </span>ADDITIONAL:<span class="w"> </span><span class="m">1</span> -<span class="p">;;</span> OPT PSEUDOSECTION: -<span class="p">;</span> EDNS: version: <span class="m">0</span>, flags:<span class="p">;</span> udp: <span class="m">65494</span> -<span class="p">;;</span> QUESTION SECTION: -<span class="p">;</span>navanspi.duckdns.org. IN TXT +<span class="p">;;</span><span class="w"> </span>OPT<span class="w"> </span>PSEUDOSECTION: +<span class="p">;</span><span class="w"> </span>EDNS:<span class="w"> </span>version:<span class="w"> </span><span class="m">0</span>,<span class="w"> </span>flags:<span class="p">;</span><span class="w"> </span>udp:<span class="w"> </span><span class="m">65494</span> +<span class="p">;;</span><span class="w"> </span>QUESTION<span class="w"> </span>SECTION: +<span class="p">;</span>navanspi.duckdns.org.<span class="w"> </span>IN<span class="w"> </span>TXT -<span class="p">;;</span> ANSWER SECTION: -navanspi.duckdns.org. <span class="m">60</span> IN TXT <span class="s2">"4OKbijIJmc82Yv2NiGVm1RmaBHSCZ_230qNtj9YA-qk"</span> +<span class="p">;;</span><span class="w"> </span>ANSWER<span class="w"> </span>SECTION: +navanspi.duckdns.org.<span class="w"> </span><span class="m">60</span><span class="w"> </span>IN<span class="w"> </span>TXT<span class="w"> </span><span class="s2">"4OKbijIJmc82Yv2NiGVm1RmaBHSCZ_230qNtj9YA-qk"</span> -<span class="p">;;</span> Query time: <span class="m">275</span> msec -<span class="p">;;</span> SERVER: <span class="m">127</span>.0.0.53#53<span class="o">(</span><span class="m">127</span>.0.0.53<span class="o">)</span> -<span class="p">;;</span> WHEN: Tue Nov <span class="m">17</span> <span class="m">15</span>:23:15 IST <span class="m">2020</span> -<span class="p">;;</span> MSG SIZE rcvd: <span class="m">105</span> +<span class="p">;;</span><span class="w"> </span>Query<span class="w"> </span>time:<span class="w"> </span><span class="m">275</span><span class="w"> </span>msec +<span class="p">;;</span><span class="w"> </span>SERVER:<span class="w"> </span><span class="m">127</span>.0.0.53#53<span class="o">(</span><span class="m">127</span>.0.0.53<span class="o">)</span> +<span class="p">;;</span><span class="w"> </span>WHEN:<span class="w"> </span>Tue<span class="w"> </span>Nov<span class="w"> </span><span class="m">17</span><span class="w"> </span><span class="m">15</span>:23:15<span class="w"> </span>IST<span class="w"> </span><span class="m">2020</span> +<span class="p">;;</span><span class="w"> </span>MSG<span class="w"> </span>SIZE<span class="w"> </span>rcvd:<span class="w"> </span><span class="m">105</span> </code></pre> </div> @@ -4373,14 +4391,14 @@ navanspi.duckdns.org. <span class="m">60</span> IN TXT <span class=" <p>Example Gunicorn command for running a web-app:</p> <div class="codehilite"> -<pre><span></span><code>gunicorn api:app -k uvicorn.workers.UvicornWorker -b <span class="m">0</span>.0.0.0:7589 +<pre><span></span><code>gunicorn<span class="w"> </span>api:app<span class="w"> </span>-k<span class="w"> </span>uvicorn.workers.UvicornWorker<span class="w"> </span>-b<span class="w"> </span><span class="m">0</span>.0.0.0:7589 </code></pre> </div> <p>To use the certificate with it, simply copy the <code>cert.pem</code> and <code>privkey.pem</code> to your working directory ( change the appropriate permissions ) and include them in the command</p> <div class="codehilite"> -<pre><span></span><code>gunicorn api:app -k uvicorn.workers.UvicornWorker -b <span class="m">0</span>.0.0.0:7589 --certfile<span class="o">=</span>cert.pem --keyfile<span class="o">=</span>privkey.pem +<pre><span></span><code>gunicorn<span class="w"> </span>api:app<span class="w"> </span>-k<span class="w"> </span>uvicorn.workers.UvicornWorker<span class="w"> </span>-b<span class="w"> </span><span class="m">0</span>.0.0.0:7589<span class="w"> </span>--certfile<span class="o">=</span>cert.pem<span class="w"> </span>--keyfile<span class="o">=</span>privkey.pem </code></pre> </div> @@ -4431,7 +4449,7 @@ a CUDA compatible MXNet package.</p> <h3>Downloading the Dataset</h3> <div class="codehilite"> -<pre><span></span><code><span class="nt">!wget</span><span class="na"> -q "https</span><span class="p">:</span><span class="nc">//github.com/joolsa/fake_real_news_dataset/raw/master/fake_or_real_news.csv.zip"</span><span class="w"></span> +<pre><span></span><code><span class="nt">!wget</span><span class="na"> -q "https</span><span class="p">:</span><span class="nc">//github.com/joolsa/fake_real_news_dataset/raw/master/fake_or_real_news.csv.zip"</span> <span class="nt">!unzip</span><span class="na"> fake_or_real_news.csv.zip</span> </code></pre> </div> @@ -4704,176 +4722,176 @@ DescriptionThe bag-of-words model is a simplifying representation used in NLP, i <span class="p"></</span><span class="nt">main</span><span class="p">></span> <span class="p"><</span><span class="nt">script</span> <span class="na">src</span><span class="o">=</span><span class="s">"https://gitcdn.xyz/repo/rbren/rss-parser/master/dist/rss-parser.js"</span><span class="p">></</span><span class="nt">script</span><span class="p">></span> -<span class="p"><</span><span class="nt">script</span><span class="p">></span><span class="w"></span> - -<span class="kd">const</span><span class="w"> </span><span class="nx">feeds</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="s2">"BuzzFeed - India"</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="s2">"link"</span><span class="o">:</span><span class="s2">"https://www.buzzfeed.com/in.xml"</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="s2">"summary"</span><span class="o">:</span><span class="kc">true</span><span class="w"></span> -<span class="w"> </span><span class="p">},</span><span class="w"></span> -<span class="w"> </span><span class="s2">"New Yorker"</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="s2">"link"</span><span class="o">:</span><span class="s2">"http://www.newyorker.com/feed/news"</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="p">},</span><span class="w"></span> -<span class="w"> </span><span class="s2">"Vox"</span><span class="o">:</span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="s2">"link"</span><span class="o">:</span><span class="s2">"https://www.vox.com/rss/index.xml"</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="s2">"limit"</span><span class="o">:</span><span class="w"> </span><span class="mf">3</span><span class="w"></span> -<span class="w"> </span><span class="p">},</span><span class="w"></span> -<span class="w"> </span><span class="s2">"r/Jokes"</span><span class="o">:</span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="s2">"link"</span><span class="o">:</span><span class="s2">"https://reddit.com/r/Jokes/hot/.rss?sort=hot"</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="s2">"ignore"</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"repost"</span><span class="p">,</span><span class="s2">"discord"</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="p">}</span><span class="w"></span> - -<span class="kd">const</span><span class="w"> </span><span class="nx">config_extra</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="s2">"Responsive-Images"</span><span class="o">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w"></span> -<span class="s2">"direct-link"</span><span class="o">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w"></span> -<span class="s2">"show-date"</span><span class="o">:</span><span class="kc">false</span><span class="p">,</span><span class="w"></span> -<span class="s2">"left-column"</span><span class="o">:</span><span class="kc">false</span><span class="p">,</span><span class="w"></span> -<span class="s2">"defaults"</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="s2">"limit"</span><span class="o">:</span><span class="w"> </span><span class="mf">5</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="s2">"summary"</span><span class="o">:</span><span class="w"> </span><span class="kc">true</span><span class="w"></span> -<span class="p">}</span><span class="w"></span> -<span class="p">}</span><span class="w"></span> - -<span class="kd">const</span><span class="w"> </span><span class="nx">CORS_PROXY</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"https://cors-anywhere.herokuapp.com/"</span><span class="w"></span> - -<span class="kd">var</span><span class="w"> </span><span class="nx">contents_title</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"h2"</span><span class="p">)</span><span class="w"></span> -<span class="nx">contents_title</span><span class="p">.</span><span class="nx">textContent</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"Contents"</span><span class="w"></span> -<span class="nx">contents_title</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"pb-1"</span><span class="p">)</span><span class="w"></span> -<span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s2">"contents"</span><span class="p">).</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">contents_title</span><span class="p">)</span><span class="w"></span> - -<span class="k">async</span><span class="w"> </span><span class="kd">function</span><span class="w"> </span><span class="nx">myfunc</span><span class="p">(</span><span class="nx">key</span><span class="p">){</span><span class="w"></span> - -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">count_lim</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">feeds</span><span class="p">[</span><span class="nx">key</span><span class="p">][</span><span class="s2">"limit"</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">count_lim</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="nx">count_lim</span><span class="w"> </span><span class="o">===</span><span class="w"> </span><span class="kc">undefined</span><span class="p">)</span><span class="w"> </span><span class="o">?</span><span class="w"> </span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">"defaults"</span><span class="p">][</span><span class="s2">"limit"</span><span class="p">]</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="nx">count_lim</span><span class="w"></span> - -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">show_summary</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">feeds</span><span class="p">[</span><span class="nx">key</span><span class="p">][</span><span class="s2">"summary"</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">show_summary</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="nx">show_summary</span><span class="w"> </span><span class="o">===</span><span class="w"> </span><span class="kc">undefined</span><span class="p">)</span><span class="w"> </span><span class="o">?</span><span class="w"> </span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">"defaults"</span><span class="p">][</span><span class="s2">"summary"</span><span class="p">]</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="nx">show_summary</span><span class="w"></span> - -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">ignore_tags</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">feeds</span><span class="p">[</span><span class="nx">key</span><span class="p">][</span><span class="s2">"ignore"</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">ignore_tags</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="nx">ignore_tags</span><span class="w"> </span><span class="o">===</span><span class="w"> </span><span class="kc">undefined</span><span class="p">)</span><span class="w"> </span><span class="o">?</span><span class="w"> </span><span class="p">[]</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="nx">ignore_tags</span><span class="w"></span> - -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">contents</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"a"</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="nx">contents</span><span class="p">.</span><span class="nx">href</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"#"</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">key</span><span class="w"></span> -<span class="w"> </span><span class="nx">contents</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"list-group-item"</span><span class="p">,</span><span class="s2">"list-group-item-action"</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="nx">contents</span><span class="p">.</span><span class="nx">textContent</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">key</span><span class="w"></span> -<span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s2">"contents"</span><span class="p">).</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">contents</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">feed_div</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"div"</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="nx">feed_div</span><span class="p">.</span><span class="nx">id</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">key</span><span class="w"></span> -<span class="w"> </span><span class="nx">feed_div</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="s2">"id"</span><span class="p">,</span><span class="w"> </span><span class="nx">key</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">title</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"h2"</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="nx">title</span><span class="p">.</span><span class="nx">textContent</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"From "</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">key</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="nx">title</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"pb-1"</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="nx">feed_div</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">title</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s2">"feed"</span><span class="p">).</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">feed_div</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">parser</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="ow">new</span><span class="w"> </span><span class="nx">RSSParser</span><span class="p">();</span><span class="w"></span> -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">countPosts</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="w"></span> -<span class="w"> </span><span class="nx">parser</span><span class="p">.</span><span class="nx">parseURL</span><span class="p">(</span><span class="nx">CORS_PROXY</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">feeds</span><span class="p">[</span><span class="nx">key</span><span class="p">][</span><span class="s2">"link"</span><span class="p">],</span><span class="w"> </span><span class="kd">function</span><span class="p">(</span><span class="nx">err</span><span class="p">,</span><span class="w"> </span><span class="nx">feed</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">err</span><span class="p">)</span><span class="w"> </span><span class="k">throw</span><span class="w"> </span><span class="nx">err</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="nx">feed</span><span class="p">.</span><span class="nx">items</span><span class="p">.</span><span class="nx">forEach</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">entry</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">countPosts</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">count_lim</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">skip</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">false</span><span class="w"></span> -<span class="w"> </span><span class="k">for</span><span class="p">(</span><span class="kd">var</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">ignore_tags</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">entry</span><span class="p">.</span><span class="nx">title</span><span class="p">.</span><span class="nx">includes</span><span class="p">(</span><span class="nx">ignore_tags</span><span class="p">[</span><span class="nx">i</span><span class="p">])){</span><span class="w"></span> -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">skip</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">true</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">entry</span><span class="p">.</span><span class="nx">content</span><span class="p">.</span><span class="nx">includes</span><span class="p">(</span><span class="nx">ignore_tags</span><span class="p">[</span><span class="nx">i</span><span class="p">])){</span><span class="w"></span> -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">skip</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">true</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> - -<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="o">!</span><span class="nx">skip</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">node</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"div"</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="nx">node</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"card"</span><span class="p">,</span><span class="s2">"mb-3"</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">row</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"div"</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="nx">row</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"row"</span><span class="p">,</span><span class="s2">"no-gutters"</span><span class="p">)</span><span class="w"></span> - -<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">"left-column"</span><span class="p">]){</span><span class="w"></span> -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">left_col</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"div"</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="nx">left_col</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"col-md-2"</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">left_col_body</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"div"</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="nx">left_col_body</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"card-body"</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> - -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">right_col</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"div"</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">"left-column"</span><span class="p">]){</span><span class="w"></span> -<span class="w"> </span><span class="nx">right_col</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"col-md-10"</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">node_title</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"h5"</span><span class="p">)</span><span class="w"></span> - -<span class="w"> </span><span class="nx">node_title</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"card-header"</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="nx">node_title</span><span class="p">.</span><span class="nx">innerHTML</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">entry</span><span class="p">.</span><span class="nx">title</span><span class="w"></span> - -<span class="w"> </span><span class="nx">node_body</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"div"</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="nx">node_body</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"card-body"</span><span class="p">)</span><span class="w"></span> - -<span class="w"> </span><span class="nx">node_content</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"p"</span><span class="p">)</span><span class="w"></span> - -<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">show_summary</span><span class="p">){</span><span class="w"></span> -<span class="w"> </span><span class="nx">node_content</span><span class="p">.</span><span class="nx">innerHTML</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">entry</span><span class="p">.</span><span class="nx">content</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="w"> </span><span class="nx">node_content</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"card-text"</span><span class="p">)</span><span class="w"></span> - -<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">"direct-link"</span><span class="p">]){</span><span class="w"></span> -<span class="w"> </span><span class="nx">node_link</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"p"</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="nx">node_link</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"card-text"</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="nx">node_link</span><span class="p">.</span><span class="nx">innerHTML</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"<b>Link:</b> <a href='"</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">entry</span><span class="p">.</span><span class="nx">link</span><span class="w"> </span><span class="o">+</span><span class="s2">"'>Direct Link</a>"</span><span class="w"></span> -<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">"left-column"</span><span class="p">]){</span><span class="w"></span> -<span class="w"> </span><span class="nx">left_col_body</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">node_link</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="nx">node_content</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">node_link</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> - -<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">"show-date"</span><span class="p">]){</span><span class="w"></span> -<span class="w"> </span><span class="nx">node_date</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"p"</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="nx">node_date</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"card-text"</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="nx">node_date</span><span class="p">.</span><span class="nx">innerHTML</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"<p><b>Date: </b>"</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">entry</span><span class="p">.</span><span class="nx">pubDate</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="s2">"</p>"</span><span class="w"></span> -<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">"left-column"</span><span class="p">]){</span><span class="w"></span> -<span class="w"> </span><span class="nx">left_col_body</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">node_date</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="nx">node_content</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">node_date</span><span class="p">)</span><span class="w"></span> - -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> - -<span class="w"> </span><span class="nx">node</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">node_title</span><span class="p">)</span><span class="w"></span> - -<span class="w"> </span><span class="nx">node_body</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">node_content</span><span class="p">)</span><span class="w"></span> - -<span class="w"> </span><span class="nx">right_col</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">node_body</span><span class="p">)</span><span class="w"></span> - -<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">"left-column"</span><span class="p">]){</span><span class="w"></span> -<span class="w"> </span><span class="nx">left_col</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">left_col_body</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="nx">row</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">left_col</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> - -<span class="w"> </span><span class="nx">row</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">right_col</span><span class="p">)</span><span class="w"></span> - -<span class="w"> </span><span class="nx">node</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">row</span><span class="p">)</span><span class="w"></span> - -<span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="nx">key</span><span class="p">).</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">node</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="nx">countPosts</span><span class="o">+=</span><span class="mf">1</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="w"> </span><span class="p">})</span><span class="w"></span> - -<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">"Responsive-Images"</span><span class="p">]){</span><span class="w"></span> -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">inputs</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementsByTagName</span><span class="p">(</span><span class="s1">'img'</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="k">for</span><span class="p">(</span><span class="kd">var</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">inputs</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="nx">inputs</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"img-fluid"</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> - -<span class="w"> </span><span class="p">})</span><span class="w"></span> - -<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="kc">true</span><span class="w"></span> -<span class="p">}</span><span class="w"></span> -<span class="p">(</span><span class="k">async</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="k">for</span><span class="p">(</span><span class="kd">var</span><span class="w"> </span><span class="nx">key</span><span class="w"> </span><span class="ow">in</span><span class="w"> </span><span class="nx">feeds</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">result</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">await</span><span class="w"> </span><span class="nx">myfunc</span><span class="p">(</span><span class="nx">key</span><span class="p">);</span><span class="w"></span> -<span class="p">}})();</span><span class="w"></span> +<span class="p"><</span><span class="nt">script</span><span class="p">></span> + +<span class="kd">const</span><span class="w"> </span><span class="nx">feeds</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="s2">"BuzzFeed - India"</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="s2">"link"</span><span class="o">:</span><span class="s2">"https://www.buzzfeed.com/in.xml"</span><span class="p">,</span> +<span class="w"> </span><span class="s2">"summary"</span><span class="o">:</span><span class="kc">true</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="s2">"New Yorker"</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="s2">"link"</span><span class="o">:</span><span class="s2">"http://www.newyorker.com/feed/news"</span><span class="p">,</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="s2">"Vox"</span><span class="o">:</span><span class="p">{</span> +<span class="w"> </span><span class="s2">"link"</span><span class="o">:</span><span class="s2">"https://www.vox.com/rss/index.xml"</span><span class="p">,</span> +<span class="w"> </span><span class="s2">"limit"</span><span class="o">:</span><span class="w"> </span><span class="mf">3</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="s2">"r/Jokes"</span><span class="o">:</span><span class="p">{</span> +<span class="w"> </span><span class="s2">"link"</span><span class="o">:</span><span class="s2">"https://reddit.com/r/Jokes/hot/.rss?sort=hot"</span><span class="p">,</span> +<span class="w"> </span><span class="s2">"ignore"</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"repost"</span><span class="p">,</span><span class="s2">"discord"</span><span class="p">]</span> +<span class="w"> </span><span class="p">}</span> +<span class="p">}</span> + +<span class="kd">const</span><span class="w"> </span><span class="nx">config_extra</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span> +<span class="s2">"Responsive-Images"</span><span class="o">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span> +<span class="s2">"direct-link"</span><span class="o">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span> +<span class="s2">"show-date"</span><span class="o">:</span><span class="kc">false</span><span class="p">,</span> +<span class="s2">"left-column"</span><span class="o">:</span><span class="kc">false</span><span class="p">,</span> +<span class="s2">"defaults"</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="s2">"limit"</span><span class="o">:</span><span class="w"> </span><span class="mf">5</span><span class="p">,</span> +<span class="w"> </span><span class="s2">"summary"</span><span class="o">:</span><span class="w"> </span><span class="kc">true</span> +<span class="p">}</span> +<span class="p">}</span> + +<span class="kd">const</span><span class="w"> </span><span class="nx">CORS_PROXY</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"https://cors-anywhere.herokuapp.com/"</span> + +<span class="kd">var</span><span class="w"> </span><span class="nx">contents_title</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"h2"</span><span class="p">)</span> +<span class="nx">contents_title</span><span class="p">.</span><span class="nx">textContent</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"Contents"</span> +<span class="nx">contents_title</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"pb-1"</span><span class="p">)</span> +<span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s2">"contents"</span><span class="p">).</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">contents_title</span><span class="p">)</span> + +<span class="k">async</span><span class="w"> </span><span class="kd">function</span><span class="w"> </span><span class="nx">myfunc</span><span class="p">(</span><span class="nx">key</span><span class="p">){</span> + +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">count_lim</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">feeds</span><span class="p">[</span><span class="nx">key</span><span class="p">][</span><span class="s2">"limit"</span><span class="p">]</span> +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">count_lim</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="nx">count_lim</span><span class="w"> </span><span class="o">===</span><span class="w"> </span><span class="kc">undefined</span><span class="p">)</span><span class="w"> </span><span class="o">?</span><span class="w"> </span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">"defaults"</span><span class="p">][</span><span class="s2">"limit"</span><span class="p">]</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="nx">count_lim</span> + +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">show_summary</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">feeds</span><span class="p">[</span><span class="nx">key</span><span class="p">][</span><span class="s2">"summary"</span><span class="p">]</span> +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">show_summary</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="nx">show_summary</span><span class="w"> </span><span class="o">===</span><span class="w"> </span><span class="kc">undefined</span><span class="p">)</span><span class="w"> </span><span class="o">?</span><span class="w"> </span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">"defaults"</span><span class="p">][</span><span class="s2">"summary"</span><span class="p">]</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="nx">show_summary</span> + +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">ignore_tags</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">feeds</span><span class="p">[</span><span class="nx">key</span><span class="p">][</span><span class="s2">"ignore"</span><span class="p">]</span> +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">ignore_tags</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="nx">ignore_tags</span><span class="w"> </span><span class="o">===</span><span class="w"> </span><span class="kc">undefined</span><span class="p">)</span><span class="w"> </span><span class="o">?</span><span class="w"> </span><span class="p">[]</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="nx">ignore_tags</span> + +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">contents</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"a"</span><span class="p">)</span> +<span class="w"> </span><span class="nx">contents</span><span class="p">.</span><span class="nx">href</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"#"</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">key</span> +<span class="w"> </span><span class="nx">contents</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"list-group-item"</span><span class="p">,</span><span class="s2">"list-group-item-action"</span><span class="p">)</span> +<span class="w"> </span><span class="nx">contents</span><span class="p">.</span><span class="nx">textContent</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">key</span> +<span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s2">"contents"</span><span class="p">).</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">contents</span><span class="p">)</span> +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">feed_div</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"div"</span><span class="p">)</span> +<span class="w"> </span><span class="nx">feed_div</span><span class="p">.</span><span class="nx">id</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">key</span> +<span class="w"> </span><span class="nx">feed_div</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="s2">"id"</span><span class="p">,</span><span class="w"> </span><span class="nx">key</span><span class="p">);</span> +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">title</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"h2"</span><span class="p">);</span> +<span class="w"> </span><span class="nx">title</span><span class="p">.</span><span class="nx">textContent</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"From "</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">key</span><span class="p">;</span> +<span class="w"> </span><span class="nx">title</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"pb-1"</span><span class="p">)</span> +<span class="w"> </span><span class="nx">feed_div</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">title</span><span class="p">)</span> +<span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s2">"feed"</span><span class="p">).</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">feed_div</span><span class="p">)</span> +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">parser</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="ow">new</span><span class="w"> </span><span class="nx">RSSParser</span><span class="p">();</span> +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">countPosts</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span> +<span class="w"> </span><span class="nx">parser</span><span class="p">.</span><span class="nx">parseURL</span><span class="p">(</span><span class="nx">CORS_PROXY</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">feeds</span><span class="p">[</span><span class="nx">key</span><span class="p">][</span><span class="s2">"link"</span><span class="p">],</span><span class="w"> </span><span class="kd">function</span><span class="p">(</span><span class="nx">err</span><span class="p">,</span><span class="w"> </span><span class="nx">feed</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">err</span><span class="p">)</span><span class="w"> </span><span class="k">throw</span><span class="w"> </span><span class="nx">err</span><span class="p">;</span> +<span class="w"> </span><span class="nx">feed</span><span class="p">.</span><span class="nx">items</span><span class="p">.</span><span class="nx">forEach</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">entry</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">countPosts</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">count_lim</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> + +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">skip</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">false</span> +<span class="w"> </span><span class="k">for</span><span class="p">(</span><span class="kd">var</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">ignore_tags</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">entry</span><span class="p">.</span><span class="nx">title</span><span class="p">.</span><span class="nx">includes</span><span class="p">(</span><span class="nx">ignore_tags</span><span class="p">[</span><span class="nx">i</span><span class="p">])){</span> +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">skip</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">true</span> +<span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">entry</span><span class="p">.</span><span class="nx">content</span><span class="p">.</span><span class="nx">includes</span><span class="p">(</span><span class="nx">ignore_tags</span><span class="p">[</span><span class="nx">i</span><span class="p">])){</span> +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">skip</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">true</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="p">}</span> + +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="o">!</span><span class="nx">skip</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> + +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">node</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"div"</span><span class="p">);</span> +<span class="w"> </span><span class="nx">node</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"card"</span><span class="p">,</span><span class="s2">"mb-3"</span><span class="p">);</span> +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">row</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"div"</span><span class="p">)</span> +<span class="w"> </span><span class="nx">row</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"row"</span><span class="p">,</span><span class="s2">"no-gutters"</span><span class="p">)</span> + +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">"left-column"</span><span class="p">]){</span> +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">left_col</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"div"</span><span class="p">)</span> +<span class="w"> </span><span class="nx">left_col</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"col-md-2"</span><span class="p">)</span> +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">left_col_body</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"div"</span><span class="p">)</span> +<span class="w"> </span><span class="nx">left_col_body</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"card-body"</span><span class="p">)</span> +<span class="w"> </span><span class="p">}</span> + +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">right_col</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"div"</span><span class="p">)</span> +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">"left-column"</span><span class="p">]){</span> +<span class="w"> </span><span class="nx">right_col</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"col-md-10"</span><span class="p">)</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">node_title</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"h5"</span><span class="p">)</span> + +<span class="w"> </span><span class="nx">node_title</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"card-header"</span><span class="p">)</span> +<span class="w"> </span><span class="nx">node_title</span><span class="p">.</span><span class="nx">innerHTML</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">entry</span><span class="p">.</span><span class="nx">title</span> + +<span class="w"> </span><span class="nx">node_body</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"div"</span><span class="p">)</span> +<span class="w"> </span><span class="nx">node_body</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"card-body"</span><span class="p">)</span> + +<span class="w"> </span><span class="nx">node_content</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"p"</span><span class="p">)</span> + +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">show_summary</span><span class="p">){</span> +<span class="w"> </span><span class="nx">node_content</span><span class="p">.</span><span class="nx">innerHTML</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">entry</span><span class="p">.</span><span class="nx">content</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="nx">node_content</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"card-text"</span><span class="p">)</span> + +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">"direct-link"</span><span class="p">]){</span> +<span class="w"> </span><span class="nx">node_link</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"p"</span><span class="p">)</span> +<span class="w"> </span><span class="nx">node_link</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"card-text"</span><span class="p">)</span> +<span class="w"> </span><span class="nx">node_link</span><span class="p">.</span><span class="nx">innerHTML</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"<b>Link:</b> <a href='"</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">entry</span><span class="p">.</span><span class="nx">link</span><span class="w"> </span><span class="o">+</span><span class="s2">"'>Direct Link</a>"</span> +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">"left-column"</span><span class="p">]){</span> +<span class="w"> </span><span class="nx">left_col_body</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">node_link</span><span class="p">)</span> +<span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">node_content</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">node_link</span><span class="p">)</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="p">}</span> + +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">"show-date"</span><span class="p">]){</span> +<span class="w"> </span><span class="nx">node_date</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"p"</span><span class="p">)</span> +<span class="w"> </span><span class="nx">node_date</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"card-text"</span><span class="p">)</span> +<span class="w"> </span><span class="nx">node_date</span><span class="p">.</span><span class="nx">innerHTML</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"<p><b>Date: </b>"</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">entry</span><span class="p">.</span><span class="nx">pubDate</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="s2">"</p>"</span> +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">"left-column"</span><span class="p">]){</span> +<span class="w"> </span><span class="nx">left_col_body</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">node_date</span><span class="p">)</span> +<span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">node_content</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">node_date</span><span class="p">)</span> + +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="p">}</span> + +<span class="w"> </span><span class="nx">node</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">node_title</span><span class="p">)</span> + +<span class="w"> </span><span class="nx">node_body</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">node_content</span><span class="p">)</span> + +<span class="w"> </span><span class="nx">right_col</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">node_body</span><span class="p">)</span> + +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">"left-column"</span><span class="p">]){</span> +<span class="w"> </span><span class="nx">left_col</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">left_col_body</span><span class="p">)</span> +<span class="w"> </span><span class="nx">row</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">left_col</span><span class="p">)</span> +<span class="w"> </span><span class="p">}</span> + +<span class="w"> </span><span class="nx">row</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">right_col</span><span class="p">)</span> + +<span class="w"> </span><span class="nx">node</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">row</span><span class="p">)</span> + +<span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="nx">key</span><span class="p">).</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">node</span><span class="p">)</span> +<span class="w"> </span><span class="nx">countPosts</span><span class="o">+=</span><span class="mf">1</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="p">})</span> + +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">"Responsive-Images"</span><span class="p">]){</span> +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">inputs</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementsByTagName</span><span class="p">(</span><span class="s1">'img'</span><span class="p">)</span> +<span class="w"> </span><span class="k">for</span><span class="p">(</span><span class="kd">var</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">inputs</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">inputs</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"img-fluid"</span><span class="p">)</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="p">}</span> + +<span class="w"> </span><span class="p">})</span> + +<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="kc">true</span> +<span class="p">}</span> +<span class="p">(</span><span class="k">async</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="p">{</span> +<span class="k">for</span><span class="p">(</span><span class="kd">var</span><span class="w"> </span><span class="nx">key</span><span class="w"> </span><span class="ow">in</span><span class="w"> </span><span class="nx">feeds</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">result</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">await</span><span class="w"> </span><span class="nx">myfunc</span><span class="p">(</span><span class="nx">key</span><span class="p">);</span> +<span class="p">}})();</span> <span class="p"></</span><span class="nt">script</span><span class="p">></span> <span class="p"><</span><span class="nt">noscript</span><span class="p">></span>Uh Oh! Your browser does not support JavaScript or JavaScript is currently disabled. Please enable JavaScript or switch to a different browser.<span class="p"></</span><span class="nt">noscript</span><span class="p">></span> @@ -5262,46 +5280,46 @@ Seeing that you are reading this on Mastodon, and that I have updated this secti <pre><span></span><code><span class="cm">/*</span> <span class="cm"> * Earth - Sun Orbit Plot</span> <span class="cm"> * Taken from Numerics tutorial</span> -<span class="cm"> */</span><span class="w"></span> - -<span class="kd">const</span><span class="w"> </span><span class="nx">G</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">6.67e-11</span><span class="p">;</span><span class="w"></span> -<span class="kd">const</span><span class="w"> </span><span class="nx">Msun</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">2e30</span><span class="p">;</span><span class="w"></span> -<span class="kd">const</span><span class="w"> </span><span class="nx">AU</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">1.5e11</span><span class="p">;</span><span class="w"></span> -<span class="kd">const</span><span class="w"> </span><span class="nx">v0</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sqrt</span><span class="p">(</span><span class="nx">G</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">Msun</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nx">AU</span><span class="p">);</span><span class="w"> </span><span class="c1">// SI</span><span class="w"></span> - -<span class="kd">function</span><span class="w"> </span><span class="nx">dR</span><span class="p">(</span><span class="nx">r</span><span class="p">,</span><span class="w"> </span><span class="nx">v</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">dv</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="nx">G</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">Msun</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">pow</span><span class="p">(</span><span class="nx">r</span><span class="p">[</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">**</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">r</span><span class="p">[</span><span class="mf">1</span><span class="p">]</span><span class="w"> </span><span class="o">**</span><span class="w"> </span><span class="mf">2</span><span class="p">,</span><span class="w"> </span><span class="mf">3</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">2</span><span class="p">)</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">r</span><span class="p">[</span><span class="mf">0</span><span class="p">],</span><span class="w"> </span><span class="o">-</span><span class="nx">G</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">Msun</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">pow</span><span class="p">(</span><span class="nx">r</span><span class="p">[</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">**</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">r</span><span class="p">[</span><span class="mf">1</span><span class="p">]</span><span class="w"> </span><span class="o">**</span><span class="w"> </span><span class="mf">2</span><span class="p">,</span><span class="w"> </span><span class="mf">3</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">2</span><span class="p">)</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">r</span><span class="p">[</span><span class="mf">1</span><span class="p">]];</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">dr</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[...</span><span class="nx">v</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="p">[</span><span class="nx">dr</span><span class="p">,</span><span class="w"> </span><span class="nx">dv</span><span class="p">];</span><span class="w"></span> -<span class="p">}</span><span class="w"></span> - -<span class="c1">// initialize system</span><span class="w"></span> -<span class="kd">let</span><span class="w"> </span><span class="nx">r</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="nx">AU</span><span class="p">,</span><span class="w"> </span><span class="mf">0</span><span class="p">];</span><span class="w"></span> -<span class="kd">const</span><span class="w"> </span><span class="nx">theta</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">atan2</span><span class="p">(</span><span class="nx">r</span><span class="p">[</span><span class="mf">1</span><span class="p">],</span><span class="w"> </span><span class="nx">r</span><span class="p">[</span><span class="mf">0</span><span class="p">]);</span><span class="w"></span> -<span class="kd">let</span><span class="w"> </span><span class="nx">v</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="nx">v0</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sin</span><span class="p">(</span><span class="nx">theta</span><span class="p">),</span><span class="w"> </span><span class="nx">v0</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">cos</span><span class="p">(</span><span class="nx">theta</span><span class="p">)];</span><span class="w"></span> - -<span class="kd">const</span><span class="w"> </span><span class="nx">t</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Array</span><span class="p">.</span><span class="kr">from</span><span class="p">({</span><span class="w"> </span><span class="nx">length</span><span class="o">:</span><span class="w"> </span><span class="mf">1001</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="p">(</span><span class="nx">_</span><span class="p">,</span><span class="w"> </span><span class="nx">i</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">100</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mf">0.0</span><span class="p">);</span><span class="w"> </span><span class="c1">// years</span><span class="w"></span> -<span class="kd">const</span><span class="w"> </span><span class="nx">yearSec</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">365</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">24</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">3600</span><span class="p">;</span><span class="w"></span> -<span class="kd">const</span><span class="w"> </span><span class="nx">dt</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="nx">t</span><span class="p">[</span><span class="mf">1</span><span class="p">]</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">t</span><span class="p">[</span><span class="mf">0</span><span class="p">])</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">yearSec</span><span class="p">;</span><span class="w"> </span><span class="c1">// s</span><span class="w"></span> -<span class="kd">const</span><span class="w"> </span><span class="nx">x4Plot</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Array</span><span class="p">.</span><span class="kr">from</span><span class="p">({</span><span class="w"> </span><span class="nx">length</span><span class="o">:</span><span class="w"> </span><span class="nx">t</span><span class="p">.</span><span class="nx">length</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="mf">0</span><span class="p">);</span><span class="w"></span> -<span class="kd">const</span><span class="w"> </span><span class="nx">y4Plot</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Array</span><span class="p">.</span><span class="kr">from</span><span class="p">({</span><span class="w"> </span><span class="nx">length</span><span class="o">:</span><span class="w"> </span><span class="nx">t</span><span class="p">.</span><span class="nx">length</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="mf">0</span><span class="p">);</span><span class="w"></span> - -<span class="c1">// integrate using RK4!</span><span class="w"></span> -<span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kd">let</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">t</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">k1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">dR</span><span class="p">(</span><span class="nx">r</span><span class="p">,</span><span class="w"> </span><span class="nx">v</span><span class="p">).</span><span class="nx">map</span><span class="p">(</span><span class="nx">x</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">x</span><span class="p">.</span><span class="nx">map</span><span class="p">(</span><span class="nx">y</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">y</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">dt</span><span class="p">));</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">k2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">dR</span><span class="p">(</span><span class="nx">r</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">ri</span><span class="p">,</span><span class="w"> </span><span class="nx">j</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">ri</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">k1</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">2</span><span class="p">),</span><span class="w"> </span><span class="nx">v</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">vi</span><span class="p">,</span><span class="w"> </span><span class="nx">j</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">vi</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">k1</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">2</span><span class="p">)).</span><span class="nx">map</span><span class="p">(</span><span class="nx">x</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">x</span><span class="p">.</span><span class="nx">map</span><span class="p">(</span><span class="nx">y</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">y</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">dt</span><span class="p">));</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">k3</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">dR</span><span class="p">(</span><span class="nx">r</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">ri</span><span class="p">,</span><span class="w"> </span><span class="nx">j</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">ri</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">k2</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">2</span><span class="p">),</span><span class="w"> </span><span class="nx">v</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">vi</span><span class="p">,</span><span class="w"> </span><span class="nx">j</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">vi</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">k2</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">2</span><span class="p">)).</span><span class="nx">map</span><span class="p">(</span><span class="nx">x</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">x</span><span class="p">.</span><span class="nx">map</span><span class="p">(</span><span class="nx">y</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">y</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">dt</span><span class="p">));</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">k4</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">dR</span><span class="p">(</span><span class="nx">r</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">ri</span><span class="p">,</span><span class="w"> </span><span class="nx">j</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">ri</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">k3</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">j</span><span class="p">]),</span><span class="w"> </span><span class="nx">v</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">vi</span><span class="p">,</span><span class="w"> </span><span class="nx">j</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">vi</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">k3</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">j</span><span class="p">])).</span><span class="nx">map</span><span class="p">(</span><span class="nx">x</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">x</span><span class="p">.</span><span class="nx">map</span><span class="p">(</span><span class="nx">y</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">y</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">dt</span><span class="p">));</span><span class="w"></span> -<span class="w"> </span><span class="nx">r</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">r</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">ri</span><span class="p">,</span><span class="w"> </span><span class="nx">j</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">ri</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="p">(</span><span class="nx">k1</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">k2</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">k3</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">k4</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">j</span><span class="p">])</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">6</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="nx">v</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">v</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">vi</span><span class="p">,</span><span class="w"> </span><span class="nx">j</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">vi</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="p">(</span><span class="nx">k1</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">k2</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">k3</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">k4</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">j</span><span class="p">])</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">6</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="nx">x4Plot</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">r</span><span class="p">[</span><span class="mf">0</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="nx">y4Plot</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">r</span><span class="p">[</span><span class="mf">1</span><span class="p">];</span><span class="w"></span> -<span class="p">}</span><span class="w"></span> - -<span class="c1">// make data for plot</span><span class="w"></span> -<span class="kd">var</span><span class="w"> </span><span class="nx">sun</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="mf">0</span><span class="p">,</span><span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="mf">0</span><span class="w"> </span><span class="p">};</span><span class="w"></span> -<span class="kd">const</span><span class="w"> </span><span class="nx">earth</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="nx">x4Plot</span><span class="p">.</span><span class="nx">map</span><span class="p">(</span><span class="nx">x</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">x</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nx">AU</span><span class="p">),</span><span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="nx">y4Plot</span><span class="p">.</span><span class="nx">map</span><span class="p">(</span><span class="nx">y</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">y</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nx">AU</span><span class="p">)</span><span class="w"> </span><span class="p">};</span><span class="w"></span> -<span class="kd">const</span><span class="w"> </span><span class="nx">circle</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="nb">Array</span><span class="p">.</span><span class="kr">from</span><span class="p">({</span><span class="w"> </span><span class="nx">length</span><span class="o">:</span><span class="w"> </span><span class="mf">1001</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="p">(</span><span class="nx">_</span><span class="p">,</span><span class="w"> </span><span class="nx">i</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">cos</span><span class="p">(</span><span class="nx">i</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">100</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">PI</span><span class="p">)),</span><span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="nb">Array</span><span class="p">.</span><span class="kr">from</span><span class="p">({</span><span class="w"> </span><span class="nx">length</span><span class="o">:</span><span class="w"> </span><span class="mf">1001</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="p">(</span><span class="nx">_</span><span class="p">,</span><span class="w"> </span><span class="nx">i</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sin</span><span class="p">(</span><span class="nx">i</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">100</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">PI</span><span class="p">))</span><span class="w"> </span><span class="p">};</span><span class="w"></span> +<span class="cm"> */</span> + +<span class="kd">const</span><span class="w"> </span><span class="nx">G</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">6.67e-11</span><span class="p">;</span> +<span class="kd">const</span><span class="w"> </span><span class="nx">Msun</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">2e30</span><span class="p">;</span> +<span class="kd">const</span><span class="w"> </span><span class="nx">AU</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">1.5e11</span><span class="p">;</span> +<span class="kd">const</span><span class="w"> </span><span class="nx">v0</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sqrt</span><span class="p">(</span><span class="nx">G</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">Msun</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nx">AU</span><span class="p">);</span><span class="w"> </span><span class="c1">// SI</span> + +<span class="kd">function</span><span class="w"> </span><span class="nx">dR</span><span class="p">(</span><span class="nx">r</span><span class="p">,</span><span class="w"> </span><span class="nx">v</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">dv</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="nx">G</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">Msun</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">pow</span><span class="p">(</span><span class="nx">r</span><span class="p">[</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">**</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">r</span><span class="p">[</span><span class="mf">1</span><span class="p">]</span><span class="w"> </span><span class="o">**</span><span class="w"> </span><span class="mf">2</span><span class="p">,</span><span class="w"> </span><span class="mf">3</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">2</span><span class="p">)</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">r</span><span class="p">[</span><span class="mf">0</span><span class="p">],</span><span class="w"> </span><span class="o">-</span><span class="nx">G</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">Msun</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">pow</span><span class="p">(</span><span class="nx">r</span><span class="p">[</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">**</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">r</span><span class="p">[</span><span class="mf">1</span><span class="p">]</span><span class="w"> </span><span class="o">**</span><span class="w"> </span><span class="mf">2</span><span class="p">,</span><span class="w"> </span><span class="mf">3</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">2</span><span class="p">)</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">r</span><span class="p">[</span><span class="mf">1</span><span class="p">]];</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">dr</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[...</span><span class="nx">v</span><span class="p">];</span> +<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="p">[</span><span class="nx">dr</span><span class="p">,</span><span class="w"> </span><span class="nx">dv</span><span class="p">];</span> +<span class="p">}</span> + +<span class="c1">// initialize system</span> +<span class="kd">let</span><span class="w"> </span><span class="nx">r</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="nx">AU</span><span class="p">,</span><span class="w"> </span><span class="mf">0</span><span class="p">];</span> +<span class="kd">const</span><span class="w"> </span><span class="nx">theta</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">atan2</span><span class="p">(</span><span class="nx">r</span><span class="p">[</span><span class="mf">1</span><span class="p">],</span><span class="w"> </span><span class="nx">r</span><span class="p">[</span><span class="mf">0</span><span class="p">]);</span> +<span class="kd">let</span><span class="w"> </span><span class="nx">v</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="nx">v0</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sin</span><span class="p">(</span><span class="nx">theta</span><span class="p">),</span><span class="w"> </span><span class="nx">v0</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">cos</span><span class="p">(</span><span class="nx">theta</span><span class="p">)];</span> + +<span class="kd">const</span><span class="w"> </span><span class="nx">t</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Array</span><span class="p">.</span><span class="kr">from</span><span class="p">({</span><span class="w"> </span><span class="nx">length</span><span class="o">:</span><span class="w"> </span><span class="mf">1001</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="p">(</span><span class="nx">_</span><span class="p">,</span><span class="w"> </span><span class="nx">i</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">100</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mf">0.0</span><span class="p">);</span><span class="w"> </span><span class="c1">// years</span> +<span class="kd">const</span><span class="w"> </span><span class="nx">yearSec</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">365</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">24</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">3600</span><span class="p">;</span> +<span class="kd">const</span><span class="w"> </span><span class="nx">dt</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="nx">t</span><span class="p">[</span><span class="mf">1</span><span class="p">]</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">t</span><span class="p">[</span><span class="mf">0</span><span class="p">])</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">yearSec</span><span class="p">;</span><span class="w"> </span><span class="c1">// s</span> +<span class="kd">const</span><span class="w"> </span><span class="nx">x4Plot</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Array</span><span class="p">.</span><span class="kr">from</span><span class="p">({</span><span class="w"> </span><span class="nx">length</span><span class="o">:</span><span class="w"> </span><span class="nx">t</span><span class="p">.</span><span class="nx">length</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="mf">0</span><span class="p">);</span> +<span class="kd">const</span><span class="w"> </span><span class="nx">y4Plot</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Array</span><span class="p">.</span><span class="kr">from</span><span class="p">({</span><span class="w"> </span><span class="nx">length</span><span class="o">:</span><span class="w"> </span><span class="nx">t</span><span class="p">.</span><span class="nx">length</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="mf">0</span><span class="p">);</span> + +<span class="c1">// integrate using RK4!</span> +<span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kd">let</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">t</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">k1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">dR</span><span class="p">(</span><span class="nx">r</span><span class="p">,</span><span class="w"> </span><span class="nx">v</span><span class="p">).</span><span class="nx">map</span><span class="p">(</span><span class="nx">x</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">x</span><span class="p">.</span><span class="nx">map</span><span class="p">(</span><span class="nx">y</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">y</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">dt</span><span class="p">));</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">k2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">dR</span><span class="p">(</span><span class="nx">r</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">ri</span><span class="p">,</span><span class="w"> </span><span class="nx">j</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">ri</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">k1</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">2</span><span class="p">),</span><span class="w"> </span><span class="nx">v</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">vi</span><span class="p">,</span><span class="w"> </span><span class="nx">j</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">vi</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">k1</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">2</span><span class="p">)).</span><span class="nx">map</span><span class="p">(</span><span class="nx">x</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">x</span><span class="p">.</span><span class="nx">map</span><span class="p">(</span><span class="nx">y</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">y</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">dt</span><span class="p">));</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">k3</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">dR</span><span class="p">(</span><span class="nx">r</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">ri</span><span class="p">,</span><span class="w"> </span><span class="nx">j</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">ri</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">k2</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">2</span><span class="p">),</span><span class="w"> </span><span class="nx">v</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">vi</span><span class="p">,</span><span class="w"> </span><span class="nx">j</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">vi</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">k2</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">2</span><span class="p">)).</span><span class="nx">map</span><span class="p">(</span><span class="nx">x</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">x</span><span class="p">.</span><span class="nx">map</span><span class="p">(</span><span class="nx">y</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">y</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">dt</span><span class="p">));</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">k4</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">dR</span><span class="p">(</span><span class="nx">r</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">ri</span><span class="p">,</span><span class="w"> </span><span class="nx">j</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">ri</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">k3</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">j</span><span class="p">]),</span><span class="w"> </span><span class="nx">v</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">vi</span><span class="p">,</span><span class="w"> </span><span class="nx">j</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">vi</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">k3</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">j</span><span class="p">])).</span><span class="nx">map</span><span class="p">(</span><span class="nx">x</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">x</span><span class="p">.</span><span class="nx">map</span><span class="p">(</span><span class="nx">y</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">y</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">dt</span><span class="p">));</span> +<span class="w"> </span><span class="nx">r</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">r</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">ri</span><span class="p">,</span><span class="w"> </span><span class="nx">j</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">ri</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="p">(</span><span class="nx">k1</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">k2</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">k3</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">k4</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">j</span><span class="p">])</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">6</span><span class="p">);</span> +<span class="w"> </span><span class="nx">v</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">v</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">vi</span><span class="p">,</span><span class="w"> </span><span class="nx">j</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">vi</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="p">(</span><span class="nx">k1</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">k2</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">k3</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">k4</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">j</span><span class="p">])</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">6</span><span class="p">);</span> +<span class="w"> </span><span class="nx">x4Plot</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">r</span><span class="p">[</span><span class="mf">0</span><span class="p">];</span> +<span class="w"> </span><span class="nx">y4Plot</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">r</span><span class="p">[</span><span class="mf">1</span><span class="p">];</span> +<span class="p">}</span> + +<span class="c1">// make data for plot</span> +<span class="kd">var</span><span class="w"> </span><span class="nx">sun</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="mf">0</span><span class="p">,</span><span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="mf">0</span><span class="w"> </span><span class="p">};</span> +<span class="kd">const</span><span class="w"> </span><span class="nx">earth</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="nx">x4Plot</span><span class="p">.</span><span class="nx">map</span><span class="p">(</span><span class="nx">x</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">x</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nx">AU</span><span class="p">),</span><span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="nx">y4Plot</span><span class="p">.</span><span class="nx">map</span><span class="p">(</span><span class="nx">y</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">y</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nx">AU</span><span class="p">)</span><span class="w"> </span><span class="p">};</span> +<span class="kd">const</span><span class="w"> </span><span class="nx">circle</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="nb">Array</span><span class="p">.</span><span class="kr">from</span><span class="p">({</span><span class="w"> </span><span class="nx">length</span><span class="o">:</span><span class="w"> </span><span class="mf">1001</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="p">(</span><span class="nx">_</span><span class="p">,</span><span class="w"> </span><span class="nx">i</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">cos</span><span class="p">(</span><span class="nx">i</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">100</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">PI</span><span class="p">)),</span><span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="nb">Array</span><span class="p">.</span><span class="kr">from</span><span class="p">({</span><span class="w"> </span><span class="nx">length</span><span class="o">:</span><span class="w"> </span><span class="mf">1001</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="p">(</span><span class="nx">_</span><span class="p">,</span><span class="w"> </span><span class="nx">i</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sin</span><span class="p">(</span><span class="nx">i</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">100</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">PI</span><span class="p">))</span><span class="w"> </span><span class="p">};</span> </code></pre> </div> @@ -5323,76 +5341,77 @@ Next, the function dR takes the position r and velocity v of Earth as input and <h3>Plotting the orbit</h3> -<p>Now that we have the data for the Sun's position, Earth's orbit, and the reference circle, we can plot them using Plotly.js. - <div class="codehilite"> - <pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="nx">traceSun</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="nx">sun</span><span class="p">.</span><span class="nx">x</span><span class="p">],</span><span class="w"></span> - <span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="nx">sun</span><span class="p">.</span><span class="nx">y</span><span class="p">],</span><span class="w"></span> - <span class="w"> </span><span class="nx">mode</span><span class="o">:</span><span class="w"> </span><span class="s2">"markers"</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">marker</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">symbol</span><span class="o">:</span><span class="w"> </span><span class="s2">"star"</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">size</span><span class="o">:</span><span class="w"> </span><span class="mf">10</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">color</span><span class="o">:</span><span class="w"> </span><span class="s2">"gold"</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="w"> </span><span class="nx">name</span><span class="o">:</span><span class="w"> </span><span class="s2">"Sun"</span><span class="p">,</span><span class="w"></span> - <span class="p">};</span><span class="w"></span> - <br /> - <span class="kd">const</span><span class="w"> </span><span class="nx">traceEarth</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="nx">earth</span><span class="p">.</span><span class="nx">x</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="nx">earth</span><span class="p">.</span><span class="nx">y</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">mode</span><span class="o">:</span><span class="w"> </span><span class="s2">"lines"</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">line</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">color</span><span class="o">:</span><span class="w"> </span><span class="s2">"white"</span><span class="w"></span> - <span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="w"> </span><span class="nx">name</span><span class="o">:</span><span class="w"> </span><span class="s2">"Earth"</span><span class="p">,</span><span class="w"></span> - <span class="p">};</span><span class="w"></span> - <br /> - <span class="kd">const</span><span class="w"> </span><span class="nx">traceOrbit</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="nx">circle</span><span class="p">.</span><span class="nx">x</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="nx">circle</span><span class="p">.</span><span class="nx">y</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">mode</span><span class="o">:</span><span class="w"> </span><span class="s2">"lines"</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">line</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">color</span><span class="o">:</span><span class="w"> </span><span class="s2">"crimson"</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">dash</span><span class="o">:</span><span class="w"> </span><span class="s2">"dash"</span><span class="w"></span> - <span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="w"> </span><span class="nx">name</span><span class="o">:</span><span class="w"> </span><span class="s2">"1 AU Circle"</span><span class="p">,</span><span class="w"></span> - <span class="p">};</span><span class="w"></span> - <br /> - <span class="kd">const</span><span class="w"> </span><span class="nx">earthSunLayout</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">title</span><span class="o">:</span><span class="w"> </span><span class="s2">"Earth-Sun Orbit"</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">xaxis</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">title</span><span class="o">:</span><span class="w"> </span><span class="s2">"x [AU]"</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">range</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="mf">1.1</span><span class="p">,</span><span class="mf">1.1</span><span class="p">],</span><span class="w"></span> - <span class="w"> </span><span class="nx">showgrid</span><span class="o">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">gridcolor</span><span class="o">:</span><span class="w"> </span><span class="s2">"rgba(255,255,255,0.5)"</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">gridwidth</span><span class="o">:</span><span class="w"> </span><span class="mf">1</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">zeroline</span><span class="o">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">tickmode</span><span class="o">:</span><span class="w"> </span><span class="s2">"auto"</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">nticks</span><span class="o">:</span><span class="w"> </span><span class="mf">5</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="w"> </span><span class="nx">yaxis</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">title</span><span class="o">:</span><span class="w"> </span><span class="s2">"y [AU]"</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">range</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="mf">1.1</span><span class="p">,</span><span class="mf">1.1</span><span class="p">],</span><span class="w"></span> - <span class="w"> </span><span class="nx">showgrid</span><span class="o">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">gridcolor</span><span class="o">:</span><span class="w"> </span><span class="s2">"rgba(255,255,255,0.5)"</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">gridwidth</span><span class="o">:</span><span class="w"> </span><span class="mf">1</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">zeroline</span><span class="o">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">tickmode</span><span class="o">:</span><span class="w"> </span><span class="s2">"auto"</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">nticks</span><span class="o">:</span><span class="w"> </span><span class="mf">5</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="w"> </span><span class="nx">margin</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">l</span><span class="o">:</span><span class="w"> </span><span class="mf">50</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">r</span><span class="o">:</span><span class="w"> </span><span class="mf">50</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">b</span><span class="o">:</span><span class="w"> </span><span class="mf">50</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">t</span><span class="o">:</span><span class="w"> </span><span class="mf">50</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">pad</span><span class="o">:</span><span class="w"> </span><span class="mf">4</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="w"> </span><span class="nx">paper<em>bgcolor</span><span class="o">:</span><span class="w"> </span><span class="s2">"black"</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">plot</em>bgcolor</span><span class="o">:</span><span class="w"> </span><span class="s2">"black"</span><span class="p">,</span><span class="w"></span> - <span class="p">};</span><span class="w"></span> - <span class="nx">Plotly</span><span class="p">.</span><span class="nx">newPlot</span><span class="p">(</span><span class="s2">"plot"</span><span class="p">,[</span><span class="nx">traceSun</span><span class="p">,</span><span class="nx">traceEarth</span><span class="p">,</span><span class="nx">traceOrbit</span><span class="p">],</span><span class="w"> </span><span class="nx">earthSunLayout</span><span class="p">);</span><span class="w"></span> - </code></pre> - </div></p> +<p>Now that we have the data for the Sun's position, Earth's orbit, and the reference circle, we can plot them using Plotly.js.</p> + +<div class="codehilite"> +<pre><span></span><code><span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">traceSun</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="nx">sun</span><span class="p">.</span><span class="nx">x</span><span class="p">],</span> +<span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="nx">sun</span><span class="p">.</span><span class="nx">y</span><span class="p">],</span> +<span class="w"> </span><span class="nx">mode</span><span class="o">:</span><span class="w"> </span><span class="s2">"markers"</span><span class="p">,</span> +<span class="w"> </span><span class="nx">marker</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">symbol</span><span class="o">:</span><span class="w"> </span><span class="s2">"star"</span><span class="p">,</span> +<span class="w"> </span><span class="nx">size</span><span class="o">:</span><span class="w"> </span><span class="mf">10</span><span class="p">,</span> +<span class="w"> </span><span class="nx">color</span><span class="o">:</span><span class="w"> </span><span class="s2">"gold"</span><span class="p">,</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="nx">name</span><span class="o">:</span><span class="w"> </span><span class="s2">"Sun"</span><span class="p">,</span> +<span class="w"> </span><span class="p">};</span> + +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">traceEarth</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="nx">earth</span><span class="p">.</span><span class="nx">x</span><span class="p">,</span> +<span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="nx">earth</span><span class="p">.</span><span class="nx">y</span><span class="p">,</span> +<span class="w"> </span><span class="nx">mode</span><span class="o">:</span><span class="w"> </span><span class="s2">"lines"</span><span class="p">,</span> +<span class="w"> </span><span class="nx">line</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">color</span><span class="o">:</span><span class="w"> </span><span class="s2">"white"</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="nx">name</span><span class="o">:</span><span class="w"> </span><span class="s2">"Earth"</span><span class="p">,</span> +<span class="w"> </span><span class="p">};</span> + +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">traceOrbit</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="nx">circle</span><span class="p">.</span><span class="nx">x</span><span class="p">,</span> +<span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="nx">circle</span><span class="p">.</span><span class="nx">y</span><span class="p">,</span> +<span class="w"> </span><span class="nx">mode</span><span class="o">:</span><span class="w"> </span><span class="s2">"lines"</span><span class="p">,</span> +<span class="w"> </span><span class="nx">line</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">color</span><span class="o">:</span><span class="w"> </span><span class="s2">"crimson"</span><span class="p">,</span> +<span class="w"> </span><span class="nx">dash</span><span class="o">:</span><span class="w"> </span><span class="s2">"dash"</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="nx">name</span><span class="o">:</span><span class="w"> </span><span class="s2">"1 AU Circle"</span><span class="p">,</span> +<span class="w"> </span><span class="p">};</span> + +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">earthSunLayout</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">title</span><span class="o">:</span><span class="w"> </span><span class="s2">"Earth-Sun Orbit"</span><span class="p">,</span> +<span class="w"> </span><span class="nx">xaxis</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">title</span><span class="o">:</span><span class="w"> </span><span class="s2">"x [AU]"</span><span class="p">,</span> +<span class="w"> </span><span class="nx">range</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="mf">1.1</span><span class="p">,</span><span class="mf">1.1</span><span class="p">],</span> +<span class="w"> </span><span class="nx">showgrid</span><span class="o">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span> +<span class="w"> </span><span class="nx">gridcolor</span><span class="o">:</span><span class="w"> </span><span class="s2">"rgba(255,255,255,0.5)"</span><span class="p">,</span> +<span class="w"> </span><span class="nx">gridwidth</span><span class="o">:</span><span class="w"> </span><span class="mf">1</span><span class="p">,</span> +<span class="w"> </span><span class="nx">zeroline</span><span class="o">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span> +<span class="w"> </span><span class="nx">tickmode</span><span class="o">:</span><span class="w"> </span><span class="s2">"auto"</span><span class="p">,</span> +<span class="w"> </span><span class="nx">nticks</span><span class="o">:</span><span class="w"> </span><span class="mf">5</span><span class="p">,</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="nx">yaxis</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">title</span><span class="o">:</span><span class="w"> </span><span class="s2">"y [AU]"</span><span class="p">,</span> +<span class="w"> </span><span class="nx">range</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="mf">1.1</span><span class="p">,</span><span class="mf">1.1</span><span class="p">],</span> +<span class="w"> </span><span class="nx">showgrid</span><span class="o">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span> +<span class="w"> </span><span class="nx">gridcolor</span><span class="o">:</span><span class="w"> </span><span class="s2">"rgba(255,255,255,0.5)"</span><span class="p">,</span> +<span class="w"> </span><span class="nx">gridwidth</span><span class="o">:</span><span class="w"> </span><span class="mf">1</span><span class="p">,</span> +<span class="w"> </span><span class="nx">zeroline</span><span class="o">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span> +<span class="w"> </span><span class="nx">tickmode</span><span class="o">:</span><span class="w"> </span><span class="s2">"auto"</span><span class="p">,</span> +<span class="w"> </span><span class="nx">nticks</span><span class="o">:</span><span class="w"> </span><span class="mf">5</span><span class="p">,</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="nx">margin</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">l</span><span class="o">:</span><span class="w"> </span><span class="mf">50</span><span class="p">,</span> +<span class="w"> </span><span class="nx">r</span><span class="o">:</span><span class="w"> </span><span class="mf">50</span><span class="p">,</span> +<span class="w"> </span><span class="nx">b</span><span class="o">:</span><span class="w"> </span><span class="mf">50</span><span class="p">,</span> +<span class="w"> </span><span class="nx">t</span><span class="o">:</span><span class="w"> </span><span class="mf">50</span><span class="p">,</span> +<span class="w"> </span><span class="nx">pad</span><span class="o">:</span><span class="w"> </span><span class="mf">4</span><span class="p">,</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="nx">paper_bgcolor</span><span class="o">:</span><span class="w"> </span><span class="s2">"black"</span><span class="p">,</span> +<span class="w"> </span><span class="nx">plot_bgcolor</span><span class="o">:</span><span class="w"> </span><span class="s2">"black"</span><span class="p">,</span> +<span class="w"> </span><span class="p">};</span> +<span class="w"> </span><span class="nx">Plotly</span><span class="p">.</span><span class="nx">newPlot</span><span class="p">(</span><span class="s2">"plot"</span><span class="p">,[</span><span class="nx">traceSun</span><span class="p">,</span><span class="nx">traceEarth</span><span class="p">,</span><span class="nx">traceOrbit</span><span class="p">],</span><span class="w"> </span><span class="nx">earthSunLayout</span><span class="p">);</span> +</code></pre> +</div> <h2>Figure of 8 orbit</h2> @@ -5413,78 +5432,78 @@ Next, the function dR takes the position r and velocity v of Earth as input and <p>The code for this simulation is very similar to the Earth-Sun orbit simulation, except that we now have three bodies instead of two. We also use a different set of initial conditions to generate the figure of 8 orbit.</p> <div class="codehilite"> -<pre><span></span><code><span class="kd">function</span><span class="w"> </span><span class="nx">deltaR</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">0</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">y</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">1</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">vx</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">2</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">vy</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">3</span><span class="p">];</span><span class="w"></span> +<pre><span></span><code><span class="kd">function</span><span class="w"> </span><span class="nx">deltaR</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">0</span><span class="p">];</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">y</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">1</span><span class="p">];</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">vx</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">2</span><span class="p">];</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">vy</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">3</span><span class="p">];</span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">delta</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">clone</span><span class="p">(</span><span class="nx">coords</span><span class="p">);</span><span class="w"></span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">delta</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">clone</span><span class="p">(</span><span class="nx">coords</span><span class="p">);</span> -<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kd">let</span><span class="w"> </span><span class="nx">n</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="nx">n</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">;</span><span class="w"> </span><span class="nx">n</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">xn</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">x</span><span class="p">[</span><span class="nx">n</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">yn</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">y</span><span class="p">[</span><span class="nx">n</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">deltaVx</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0.0</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">deltaVy</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0.0</span><span class="p">;</span><span class="w"></span> +<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kd">let</span><span class="w"> </span><span class="nx">n</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="nx">n</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">;</span><span class="w"> </span><span class="nx">n</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">xn</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">x</span><span class="p">[</span><span class="nx">n</span><span class="p">];</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">yn</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">y</span><span class="p">[</span><span class="nx">n</span><span class="p">];</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">deltaVx</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0.0</span><span class="p">;</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">deltaVy</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0.0</span><span class="p">;</span> -<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kd">let</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">i</span><span class="w"> </span><span class="o">!==</span><span class="w"> </span><span class="nx">n</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">sep</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sqrt</span><span class="p">(</span><span class="nb">Math</span><span class="p">.</span><span class="nx">pow</span><span class="p">(</span><span class="nx">xn</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">x</span><span class="p">[</span><span class="nx">i</span><span class="p">],</span><span class="w"> </span><span class="mf">2</span><span class="p">)</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">pow</span><span class="p">(</span><span class="nx">yn</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">y</span><span class="p">[</span><span class="nx">i</span><span class="p">],</span><span class="w"> </span><span class="mf">2</span><span class="p">));</span><span class="w"> </span><span class="c1">// Euclidean distance</span><span class="w"></span> -<span class="w"> </span><span class="nx">deltaVx</span><span class="w"> </span><span class="o">-=</span><span class="w"> </span><span class="nx">G</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="p">(</span><span class="nx">xn</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">x</span><span class="p">[</span><span class="nx">i</span><span class="p">])</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">pow</span><span class="p">(</span><span class="nx">sep</span><span class="p">,</span><span class="w"> </span><span class="mf">3</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="nx">deltaVy</span><span class="w"> </span><span class="o">-=</span><span class="w"> </span><span class="nx">G</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="p">(</span><span class="nx">yn</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">y</span><span class="p">[</span><span class="nx">i</span><span class="p">])</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">pow</span><span class="p">(</span><span class="nx">sep</span><span class="p">,</span><span class="w"> </span><span class="mf">3</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> +<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kd">let</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">i</span><span class="w"> </span><span class="o">!==</span><span class="w"> </span><span class="nx">n</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">sep</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sqrt</span><span class="p">(</span><span class="nb">Math</span><span class="p">.</span><span class="nx">pow</span><span class="p">(</span><span class="nx">xn</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">x</span><span class="p">[</span><span class="nx">i</span><span class="p">],</span><span class="w"> </span><span class="mf">2</span><span class="p">)</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">pow</span><span class="p">(</span><span class="nx">yn</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">y</span><span class="p">[</span><span class="nx">i</span><span class="p">],</span><span class="w"> </span><span class="mf">2</span><span class="p">));</span><span class="w"> </span><span class="c1">// Euclidean distance</span> +<span class="w"> </span><span class="nx">deltaVx</span><span class="w"> </span><span class="o">-=</span><span class="w"> </span><span class="nx">G</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="p">(</span><span class="nx">xn</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">x</span><span class="p">[</span><span class="nx">i</span><span class="p">])</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">pow</span><span class="p">(</span><span class="nx">sep</span><span class="p">,</span><span class="w"> </span><span class="mf">3</span><span class="p">);</span> +<span class="w"> </span><span class="nx">deltaVy</span><span class="w"> </span><span class="o">-=</span><span class="w"> </span><span class="nx">G</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="p">(</span><span class="nx">yn</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">y</span><span class="p">[</span><span class="nx">i</span><span class="p">])</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">pow</span><span class="p">(</span><span class="nx">sep</span><span class="p">,</span><span class="w"> </span><span class="mf">3</span><span class="p">);</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="p">}</span> -<span class="w"> </span><span class="nx">delta</span><span class="p">[</span><span class="mf">2</span><span class="p">][</span><span class="nx">n</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">deltaVx</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="nx">delta</span><span class="p">[</span><span class="mf">3</span><span class="p">][</span><span class="nx">n</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">deltaVy</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> +<span class="w"> </span><span class="nx">delta</span><span class="p">[</span><span class="mf">2</span><span class="p">][</span><span class="nx">n</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">deltaVx</span><span class="p">;</span> +<span class="w"> </span><span class="nx">delta</span><span class="p">[</span><span class="mf">3</span><span class="p">][</span><span class="nx">n</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">deltaVy</span><span class="p">;</span> +<span class="w"> </span><span class="p">}</span> -<span class="w"> </span><span class="nx">delta</span><span class="p">[</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">vx</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="nx">delta</span><span class="p">[</span><span class="mf">1</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">vy</span><span class="p">;</span><span class="w"></span> +<span class="w"> </span><span class="nx">delta</span><span class="p">[</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">vx</span><span class="p">;</span> +<span class="w"> </span><span class="nx">delta</span><span class="p">[</span><span class="mf">1</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">vy</span><span class="p">;</span> -<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="nx">delta</span><span class="p">;</span><span class="w"></span> -<span class="p">}</span><span class="w"></span> +<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="nx">delta</span><span class="p">;</span> +<span class="p">}</span> -<span class="kd">function</span><span class="w"> </span><span class="nx">step</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">3</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">6.67408313131313e-11</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">k1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaR</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">));</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">k2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaR</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">k1</span><span class="p">,</span><span class="w"> </span><span class="mf">0.5</span><span class="p">)),</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">));</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">k3</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaR</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">k2</span><span class="p">,</span><span class="w"> </span><span class="mf">0.5</span><span class="p">)),</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">));</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">k4</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaR</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">k3</span><span class="p">),</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">));</span><span class="w"></span> +<span class="kd">function</span><span class="w"> </span><span class="nx">step</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">3</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">6.67408313131313e-11</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">k1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaR</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">));</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">k2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaR</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">k1</span><span class="p">,</span><span class="w"> </span><span class="mf">0.5</span><span class="p">)),</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">));</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">k3</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaR</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">k2</span><span class="p">,</span><span class="w"> </span><span class="mf">0.5</span><span class="p">)),</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">));</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">k4</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaR</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">k3</span><span class="p">),</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">));</span> -<span class="w"> </span><span class="nx">coords</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">k1</span><span class="p">,</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="mf">2.0</span><span class="p">,</span><span class="w"> </span><span class="nx">k2</span><span class="p">),</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="mf">2.0</span><span class="p">,</span><span class="w"> </span><span class="nx">k3</span><span class="p">),</span><span class="w"> </span><span class="nx">k4</span><span class="p">),</span><span class="w"> </span><span class="mf">1</span><span class="o">/</span><span class="mf">6</span><span class="p">));</span><span class="w"></span> +<span class="w"> </span><span class="nx">coords</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">k1</span><span class="p">,</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="mf">2.0</span><span class="p">,</span><span class="w"> </span><span class="nx">k2</span><span class="p">),</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="mf">2.0</span><span class="p">,</span><span class="w"> </span><span class="nx">k3</span><span class="p">),</span><span class="w"> </span><span class="nx">k4</span><span class="p">),</span><span class="w"> </span><span class="mf">1</span><span class="o">/</span><span class="mf">6</span><span class="p">));</span> -<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="nx">coords</span><span class="p">;</span><span class="w"></span> -<span class="p">}</span><span class="w"></span> +<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="nx">coords</span><span class="p">;</span> +<span class="p">}</span> -<span class="w"> </span><span class="c1">// Initial conditions setup</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">M</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="mf">1</span><span class="p">,</span><span class="w"> </span><span class="mf">1</span><span class="p">,</span><span class="w"> </span><span class="mf">1</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="mf">0.97000436</span><span class="p">,</span><span class="w"> </span><span class="mf">0.0</span><span class="p">,</span><span class="w"> </span><span class="mf">0.97000436</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">y</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="mf">0.24208753</span><span class="p">,</span><span class="w"> </span><span class="mf">0.0</span><span class="p">,</span><span class="w"> </span><span class="o">-</span><span class="mf">0.24208753</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">vx</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="mf">0.4662036850</span><span class="p">,</span><span class="w"> </span><span class="o">-</span><span class="mf">0.933240737</span><span class="p">,</span><span class="w"> </span><span class="mf">0.4662036850</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">vy</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="mf">0.4323657300</span><span class="p">,</span><span class="w"> </span><span class="o">-</span><span class="mf">0.86473146</span><span class="p">,</span><span class="w"> </span><span class="mf">0.4323657300</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">Ei</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">-</span><span class="mf">1</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sqrt</span><span class="p">(</span><span class="nb">Math</span><span class="p">.</span><span class="nx">pow</span><span class="p">(</span><span class="mf">2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">0.97000436</span><span class="p">,</span><span class="w"> </span><span class="mf">2</span><span class="p">)</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">pow</span><span class="p">(</span><span class="mf">2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">0.24208753</span><span class="p">,</span><span class="w"> </span><span class="mf">2</span><span class="p">))</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sqrt</span><span class="p">(</span><span class="nb">Math</span><span class="p">.</span><span class="nx">pow</span><span class="p">(</span><span class="mf">0.97000436</span><span class="p">,</span><span class="w"> </span><span class="mf">2</span><span class="p">)</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">pow</span><span class="p">(</span><span class="mf">0.24208753</span><span class="p">,</span><span class="w"> </span><span class="mf">2</span><span class="p">))</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mf">0.5</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">sum</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">dotPow</span><span class="p">(</span><span class="nx">vx</span><span class="p">,</span><span class="w"> </span><span class="mf">2</span><span class="p">),</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">dotPow</span><span class="p">(</span><span class="nx">vy</span><span class="p">,</span><span class="w"> </span><span class="mf">2</span><span class="p">))));</span><span class="w"></span> +<span class="w"> </span><span class="c1">// Initial conditions setup</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">M</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="mf">1</span><span class="p">,</span><span class="w"> </span><span class="mf">1</span><span class="p">,</span><span class="w"> </span><span class="mf">1</span><span class="p">];</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="mf">0.97000436</span><span class="p">,</span><span class="w"> </span><span class="mf">0.0</span><span class="p">,</span><span class="w"> </span><span class="mf">0.97000436</span><span class="p">];</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">y</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="mf">0.24208753</span><span class="p">,</span><span class="w"> </span><span class="mf">0.0</span><span class="p">,</span><span class="w"> </span><span class="o">-</span><span class="mf">0.24208753</span><span class="p">];</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">vx</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="mf">0.4662036850</span><span class="p">,</span><span class="w"> </span><span class="o">-</span><span class="mf">0.933240737</span><span class="p">,</span><span class="w"> </span><span class="mf">0.4662036850</span><span class="p">];</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">vy</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="mf">0.4323657300</span><span class="p">,</span><span class="w"> </span><span class="o">-</span><span class="mf">0.86473146</span><span class="p">,</span><span class="w"> </span><span class="mf">0.4323657300</span><span class="p">];</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">Ei</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">-</span><span class="mf">1</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sqrt</span><span class="p">(</span><span class="nb">Math</span><span class="p">.</span><span class="nx">pow</span><span class="p">(</span><span class="mf">2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">0.97000436</span><span class="p">,</span><span class="w"> </span><span class="mf">2</span><span class="p">)</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">pow</span><span class="p">(</span><span class="mf">2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">0.24208753</span><span class="p">,</span><span class="w"> </span><span class="mf">2</span><span class="p">))</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sqrt</span><span class="p">(</span><span class="nb">Math</span><span class="p">.</span><span class="nx">pow</span><span class="p">(</span><span class="mf">0.97000436</span><span class="p">,</span><span class="w"> </span><span class="mf">2</span><span class="p">)</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">pow</span><span class="p">(</span><span class="mf">0.24208753</span><span class="p">,</span><span class="w"> </span><span class="mf">2</span><span class="p">))</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mf">0.5</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">sum</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">dotPow</span><span class="p">(</span><span class="nx">vx</span><span class="p">,</span><span class="w"> </span><span class="mf">2</span><span class="p">),</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">dotPow</span><span class="p">(</span><span class="nx">vy</span><span class="p">,</span><span class="w"> </span><span class="mf">2</span><span class="p">))));</span> -<span class="w"> </span><span class="kd">function</span><span class="w"> </span><span class="nx">linspace</span><span class="p">(</span><span class="nx">start</span><span class="p">,</span><span class="w"> </span><span class="nx">stop</span><span class="p">,</span><span class="w"> </span><span class="nx">num</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">step</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="nx">stop</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">start</span><span class="p">)</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="p">(</span><span class="nx">num</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mf">1</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="nb">Array</span><span class="p">.</span><span class="kr">from</span><span class="p">({</span><span class="nx">length</span><span class="o">:</span><span class="w"> </span><span class="nx">num</span><span class="p">},</span><span class="w"> </span><span class="p">(</span><span class="nx">_</span><span class="p">,</span><span class="w"> </span><span class="nx">i</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">start</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="p">(</span><span class="nx">step</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">i</span><span class="p">));</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> +<span class="w"> </span><span class="kd">function</span><span class="w"> </span><span class="nx">linspace</span><span class="p">(</span><span class="nx">start</span><span class="p">,</span><span class="w"> </span><span class="nx">stop</span><span class="p">,</span><span class="w"> </span><span class="nx">num</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">step</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="nx">stop</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">start</span><span class="p">)</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="p">(</span><span class="nx">num</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mf">1</span><span class="p">);</span> +<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="nb">Array</span><span class="p">.</span><span class="kr">from</span><span class="p">({</span><span class="nx">length</span><span class="o">:</span><span class="w"> </span><span class="nx">num</span><span class="p">},</span><span class="w"> </span><span class="p">(</span><span class="nx">_</span><span class="p">,</span><span class="w"> </span><span class="nx">i</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">start</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="p">(</span><span class="nx">step</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">i</span><span class="p">));</span> +<span class="w"> </span><span class="p">}</span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">coords</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nx">x</span><span class="p">,</span><span class="w"> </span><span class="nx">y</span><span class="p">,</span><span class="w"> </span><span class="nx">vx</span><span class="p">,</span><span class="w"> </span><span class="nx">vy</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">time</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">linspace</span><span class="p">(</span><span class="mf">0</span><span class="p">,</span><span class="w"> </span><span class="mf">6.3259</span><span class="p">,</span><span class="w"> </span><span class="mf">1001</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">deltaT</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">time</span><span class="p">[</span><span class="mf">1</span><span class="p">]</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">time</span><span class="p">[</span><span class="mf">0</span><span class="p">];</span><span class="w"></span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">coords</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nx">x</span><span class="p">,</span><span class="w"> </span><span class="nx">y</span><span class="p">,</span><span class="w"> </span><span class="nx">vx</span><span class="p">,</span><span class="w"> </span><span class="nx">vy</span><span class="p">];</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">time</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">linspace</span><span class="p">(</span><span class="mf">0</span><span class="p">,</span><span class="w"> </span><span class="mf">6.3259</span><span class="p">,</span><span class="w"> </span><span class="mf">1001</span><span class="p">);</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">deltaT</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">time</span><span class="p">[</span><span class="mf">1</span><span class="p">]</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">time</span><span class="p">[</span><span class="mf">0</span><span class="p">];</span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">X</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">zeros</span><span class="p">(</span><span class="mf">3</span><span class="p">,</span><span class="w"> </span><span class="nx">time</span><span class="p">.</span><span class="nx">length</span><span class="p">).</span><span class="nx">toArray</span><span class="p">();</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">Y</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">zeros</span><span class="p">(</span><span class="mf">3</span><span class="p">,</span><span class="w"> </span><span class="nx">time</span><span class="p">.</span><span class="nx">length</span><span class="p">).</span><span class="nx">toArray</span><span class="p">();</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">VX</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">zeros</span><span class="p">(</span><span class="mf">3</span><span class="p">,</span><span class="w"> </span><span class="nx">time</span><span class="p">.</span><span class="nx">length</span><span class="p">).</span><span class="nx">toArray</span><span class="p">();</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">VY</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">zeros</span><span class="p">(</span><span class="mf">3</span><span class="p">,</span><span class="w"> </span><span class="nx">time</span><span class="p">.</span><span class="nx">length</span><span class="p">).</span><span class="nx">toArray</span><span class="p">();</span><span class="w"></span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">X</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">zeros</span><span class="p">(</span><span class="mf">3</span><span class="p">,</span><span class="w"> </span><span class="nx">time</span><span class="p">.</span><span class="nx">length</span><span class="p">).</span><span class="nx">toArray</span><span class="p">();</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">Y</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">zeros</span><span class="p">(</span><span class="mf">3</span><span class="p">,</span><span class="w"> </span><span class="nx">time</span><span class="p">.</span><span class="nx">length</span><span class="p">).</span><span class="nx">toArray</span><span class="p">();</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">VX</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">zeros</span><span class="p">(</span><span class="mf">3</span><span class="p">,</span><span class="w"> </span><span class="nx">time</span><span class="p">.</span><span class="nx">length</span><span class="p">).</span><span class="nx">toArray</span><span class="p">();</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">VY</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">zeros</span><span class="p">(</span><span class="mf">3</span><span class="p">,</span><span class="w"> </span><span class="nx">time</span><span class="p">.</span><span class="nx">length</span><span class="p">).</span><span class="nx">toArray</span><span class="p">();</span> -<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kd">let</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">time</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="nx">coords</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">step</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">M</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="mf">3</span><span class="p">,</span><span class="w"> </span><span class="mf">1</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="nx">X</span><span class="p">.</span><span class="nx">forEach</span><span class="p">((</span><span class="nx">_</span><span class="p">,</span><span class="w"> </span><span class="nx">idx</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">X</span><span class="p">[</span><span class="nx">idx</span><span class="p">][</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">idx</span><span class="p">]);</span><span class="w"></span> -<span class="w"> </span><span class="nx">Y</span><span class="p">.</span><span class="nx">forEach</span><span class="p">((</span><span class="nx">_</span><span class="p">,</span><span class="w"> </span><span class="nx">idx</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">Y</span><span class="p">[</span><span class="nx">idx</span><span class="p">][</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">idx</span><span class="p">]);</span><span class="w"></span> -<span class="w"> </span><span class="nx">VX</span><span class="p">.</span><span class="nx">forEach</span><span class="p">((</span><span class="nx">_</span><span class="p">,</span><span class="w"> </span><span class="nx">idx</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">VX</span><span class="p">[</span><span class="nx">idx</span><span class="p">][</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">2</span><span class="p">][</span><span class="nx">idx</span><span class="p">]);</span><span class="w"></span> -<span class="w"> </span><span class="nx">VY</span><span class="p">.</span><span class="nx">forEach</span><span class="p">((</span><span class="nx">_</span><span class="p">,</span><span class="w"> </span><span class="nx">idx</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">VY</span><span class="p">[</span><span class="nx">idx</span><span class="p">][</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">3</span><span class="p">][</span><span class="nx">idx</span><span class="p">]);</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> +<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kd">let</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">time</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">coords</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">step</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">M</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="mf">3</span><span class="p">,</span><span class="w"> </span><span class="mf">1</span><span class="p">);</span> +<span class="w"> </span><span class="nx">X</span><span class="p">.</span><span class="nx">forEach</span><span class="p">((</span><span class="nx">_</span><span class="p">,</span><span class="w"> </span><span class="nx">idx</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">X</span><span class="p">[</span><span class="nx">idx</span><span class="p">][</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">idx</span><span class="p">]);</span> +<span class="w"> </span><span class="nx">Y</span><span class="p">.</span><span class="nx">forEach</span><span class="p">((</span><span class="nx">_</span><span class="p">,</span><span class="w"> </span><span class="nx">idx</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">Y</span><span class="p">[</span><span class="nx">idx</span><span class="p">][</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">idx</span><span class="p">]);</span> +<span class="w"> </span><span class="nx">VX</span><span class="p">.</span><span class="nx">forEach</span><span class="p">((</span><span class="nx">_</span><span class="p">,</span><span class="w"> </span><span class="nx">idx</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">VX</span><span class="p">[</span><span class="nx">idx</span><span class="p">][</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">2</span><span class="p">][</span><span class="nx">idx</span><span class="p">]);</span> +<span class="w"> </span><span class="nx">VY</span><span class="p">.</span><span class="nx">forEach</span><span class="p">((</span><span class="nx">_</span><span class="p">,</span><span class="w"> </span><span class="nx">idx</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">VY</span><span class="p">[</span><span class="nx">idx</span><span class="p">][</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">3</span><span class="p">][</span><span class="nx">idx</span><span class="p">]);</span> +<span class="w"> </span><span class="p">}</span> </code></pre> </div> @@ -5502,365 +5521,369 @@ Next, the function dR takes the position r and velocity v of Earth as input and <h3>Animation?</h3> -<p>Now that we have time-series data, we need to animate it. We can use Plotly's animate function, as this does not force a full re-render, saving us some precious GPU and CPU cycles when we are trying to run this in the browser itself - <div class="codehilite"> - <pre><span></span><code><span class="kd">function</span><span class="w"> </span><span class="nx">plotClassicFunc</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">tailLength</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">1</span><span class="p">;</span><span class="w"></span> - <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">plotIndex</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">tailLength</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">tailLength</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"></span> - <span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">plotIndex</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="nx">time</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">plotIndex</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"></span> - <span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">tailLength</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">plotIndex</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">tailLength</span><span class="p">;</span><span class="w"></span> - <span class="w"> </span><span class="p">}</span><span class="w"></span> - <br /> - <span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">currentIndex</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">plotIndex</span><span class="p">;</span><span class="w"></span> - <br /> - <span class="w"> </span><span class="k">try</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">time</span><span class="p">[</span><span class="nx">currentIndex</span><span class="p">].</span><span class="nx">toFixed</span><span class="p">(</span><span class="mf">3</span><span class="p">);</span><span class="w"></span> - <span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">catch</span><span class="w"> </span><span class="p">(</span><span class="nx">e</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">currentIndex</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"></span> - <span class="w"> </span><span class="p">}</span><span class="w"></span> - <br /> - <span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">data</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="w"></span> - <span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="nx">X</span><span class="p">[</span><span class="mf">0</span><span class="p">].</span><span class="nx">slice</span><span class="p">(</span><span class="nx">tailLength</span><span class="p">,</span><span class="w"> </span><span class="nx">currentIndex</span><span class="p">),</span><span class="w"></span> - <span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="nx">Y</span><span class="p">[</span><span class="mf">0</span><span class="p">].</span><span class="nx">slice</span><span class="p">(</span><span class="nx">tailLength</span><span class="p">,</span><span class="w"> </span><span class="nx">currentIndex</span><span class="p">),</span><span class="w"></span> - <span class="w"> </span><span class="nx">mode</span><span class="o">:</span><span class="w"> </span><span class="s1">'lines+markers'</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">marker</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">symbol</span><span class="o">:</span><span class="w"> </span><span class="s1">'star'</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">size</span><span class="o">:</span><span class="w"> </span><span class="mf">8</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">line</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">width</span><span class="o">:</span><span class="w"> </span><span class="mf">0</span><span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="w"> </span><span class="nx">line</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">width</span><span class="o">:</span><span class="w"> </span><span class="mf">2</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="w"> </span><span class="nx">name</span><span class="o">:</span><span class="w"> </span><span class="s1">''</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="nx">X</span><span class="p">[</span><span class="mf">1</span><span class="p">].</span><span class="nx">slice</span><span class="p">(</span><span class="nx">tailLength</span><span class="p">,</span><span class="w"> </span><span class="nx">currentIndex</span><span class="p">),</span><span class="w"></span> - <span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="nx">Y</span><span class="p">[</span><span class="mf">1</span><span class="p">].</span><span class="nx">slice</span><span class="p">(</span><span class="nx">tailLength</span><span class="p">,</span><span class="w"> </span><span class="nx">currentIndex</span><span class="p">),</span><span class="w"></span> - <span class="w"> </span><span class="nx">mode</span><span class="o">:</span><span class="w"> </span><span class="s1">'lines+markers'</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">marker</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">symbol</span><span class="o">:</span><span class="w"> </span><span class="s1">'star'</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">size</span><span class="o">:</span><span class="w"> </span><span class="mf">8</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">line</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">width</span><span class="o">:</span><span class="w"> </span><span class="mf">0</span><span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="w"> </span><span class="nx">line</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">width</span><span class="o">:</span><span class="w"> </span><span class="mf">2</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="w"> </span><span class="nx">name</span><span class="o">:</span><span class="w"> </span><span class="s1">''</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="nx">X</span><span class="p">[</span><span class="mf">2</span><span class="p">].</span><span class="nx">slice</span><span class="p">(</span><span class="nx">tailLength</span><span class="p">,</span><span class="w"> </span><span class="nx">currentIndex</span><span class="p">),</span><span class="w"></span> - <span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="nx">Y</span><span class="p">[</span><span class="mf">2</span><span class="p">].</span><span class="nx">slice</span><span class="p">(</span><span class="nx">tailLength</span><span class="p">,</span><span class="w"> </span><span class="nx">currentIndex</span><span class="p">),</span><span class="w"></span> - <span class="w"> </span><span class="nx">mode</span><span class="o">:</span><span class="w"> </span><span class="s1">'lines+markers'</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">marker</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">symbol</span><span class="o">:</span><span class="w"> </span><span class="s1">'star'</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">size</span><span class="o">:</span><span class="w"> </span><span class="mf">8</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">line</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">width</span><span class="o">:</span><span class="w"> </span><span class="mf">0</span><span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="w"> </span><span class="nx">line</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">width</span><span class="o">:</span><span class="w"> </span><span class="mf">2</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="w"> </span><span class="nx">name</span><span class="o">:</span><span class="w"> </span><span class="s1">''</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="p">];</span><span class="w"></span> - <br /> - <span class="c1">// width: 1000, height: 400</span><span class="w"></span> - <span class="kd">const</span><span class="w"> </span><span class="nx">layout</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">title</span><span class="o">:</span><span class="w"> </span><span class="s1">'∞ Three-Body Problem: t = '</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">time</span><span class="p">[</span><span class="nx">currentIndex</span><span class="p">].</span><span class="nx">toFixed</span><span class="p">(</span><span class="mf">3</span><span class="p">),</span><span class="w"></span> - <span class="w"> </span><span class="nx">xaxis</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">title</span><span class="o">:</span><span class="w"> </span><span class="s1">'x'</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">range</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="mf">1.1</span><span class="p">,</span><span class="mf">1.1</span><span class="p">]</span><span class="w"></span> - <span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="w"> </span><span class="nx">yaxis</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">title</span><span class="o">:</span><span class="w"> </span><span class="s1">'y'</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">scaleanchor</span><span class="o">:</span><span class="w"> </span><span class="s1">'x'</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">scaleratio</span><span class="o">:</span><span class="w"> </span><span class="mf">1</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">range</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="mf">0.5</span><span class="p">,</span><span class="mf">0.5</span><span class="p">]</span><span class="w"></span> - <span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="w"> </span><span class="nx">plot<em>bgcolor</span><span class="o">:</span><span class="w"> </span><span class="s1">'black'</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">paper</em>bgcolor</span><span class="o">:</span><span class="w"> </span><span class="s1">'black'</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">font</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">color</span><span class="o">:</span><span class="w"> </span><span class="s1">'white'</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="p">};</span><span class="w"></span> - <br /> - <span class="k">try</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="nx">Plotly</span><span class="p">.</span><span class="nx">animate</span><span class="p">(</span><span class="s2">"plot"</span><span class="p">,</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">data</span><span class="o">:</span><span class="w"> </span><span class="nx">data</span><span class="p">,</span><span class="w"> </span><span class="nx">layout</span><span class="o">:</span><span class="w"> </span><span class="nx">layout</span><span class="w"></span> - <span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">staticPlot</span><span class="o">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">transition</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">duration</span><span class="o">:</span><span class="w"> </span><span class="mf">0</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="w"> </span><span class="nx">frame</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">duration</span><span class="o">:</span><span class="w"> </span><span class="mf">0</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">redraw</span><span class="o">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="p">}</span><span class="w"></span> - <span class="w"> </span><span class="p">});</span><span class="w"></span> - <span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">catch</span><span class="w"> </span><span class="p">(</span><span class="nx">err</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">Plotly</span><span class="p">.</span><span class="nx">newPlot</span><span class="p">(</span><span class="s1">'plot'</span><span class="p">,</span><span class="w"> </span><span class="nx">data</span><span class="p">,</span><span class="w"> </span><span class="nx">layout</span><span class="p">);</span><span class="w"></span> - <span class="w"> </span><span class="p">}</span><span class="w"></span> - <br /> - <br /> - <span class="nx">plotIndex</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="nx">delay</span><span class="p">;</span><span class="w"></span> - <span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">plotClassic</span><span class="o">===</span><span class="kc">true</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="k">try</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">requestAnimationFrame</span><span class="p">(</span><span class="nx">plotClassicFunc</span><span class="p">);</span><span class="w"></span> - <span class="w"> </span><span class="p">}</span><span class="w"></span> - <span class="w"> </span><span class="k">catch</span><span class="w"> </span><span class="p">(</span><span class="nx">err</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span><span class="w"></span> - <span class="w"> </span><span class="p">}</span><span class="w"></span> - <span class="p">}</span><span class="w"></span> - <br /> - <span class="p">}</span><span class="w"></span> - </code></pre> - </div></p> +<p>Now that we have time-series data, we need to animate it. We can use Plotly's animate function, as this does not force a full re-render, saving us some precious GPU and CPU cycles when we are trying to run this in the browser itself</p> + +<div class="codehilite"> +<pre><span></span><code><span class="w"> </span><span class="kd">function</span><span class="w"> </span><span class="nx">plotClassicFunc</span><span class="p">()</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">tailLength</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">1</span><span class="p">;</span> +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">plotIndex</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">tailLength</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">tailLength</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span> +<span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">plotIndex</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="nx">time</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">plotIndex</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span> +<span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">tailLength</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">plotIndex</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">tailLength</span><span class="p">;</span> +<span class="w"> </span><span class="p">}</span> + +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">currentIndex</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">plotIndex</span><span class="p">;</span> + +<span class="w"> </span><span class="k">try</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">time</span><span class="p">[</span><span class="nx">currentIndex</span><span class="p">].</span><span class="nx">toFixed</span><span class="p">(</span><span class="mf">3</span><span class="p">);</span> +<span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">catch</span><span class="w"> </span><span class="p">(</span><span class="nx">e</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">currentIndex</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span> +<span class="w"> </span><span class="p">}</span> + +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">data</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span> +<span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="nx">X</span><span class="p">[</span><span class="mf">0</span><span class="p">].</span><span class="nx">slice</span><span class="p">(</span><span class="nx">tailLength</span><span class="p">,</span><span class="w"> </span><span class="nx">currentIndex</span><span class="p">),</span> +<span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="nx">Y</span><span class="p">[</span><span class="mf">0</span><span class="p">].</span><span class="nx">slice</span><span class="p">(</span><span class="nx">tailLength</span><span class="p">,</span><span class="w"> </span><span class="nx">currentIndex</span><span class="p">),</span> +<span class="w"> </span><span class="nx">mode</span><span class="o">:</span><span class="w"> </span><span class="s1">'lines+markers'</span><span class="p">,</span> +<span class="w"> </span><span class="nx">marker</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">symbol</span><span class="o">:</span><span class="w"> </span><span class="s1">'star'</span><span class="p">,</span> +<span class="w"> </span><span class="nx">size</span><span class="o">:</span><span class="w"> </span><span class="mf">8</span><span class="p">,</span> +<span class="w"> </span><span class="nx">line</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">width</span><span class="o">:</span><span class="w"> </span><span class="mf">0</span><span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="nx">line</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">width</span><span class="o">:</span><span class="w"> </span><span class="mf">2</span><span class="p">,</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="nx">name</span><span class="o">:</span><span class="w"> </span><span class="s1">''</span><span class="p">,</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="nx">X</span><span class="p">[</span><span class="mf">1</span><span class="p">].</span><span class="nx">slice</span><span class="p">(</span><span class="nx">tailLength</span><span class="p">,</span><span class="w"> </span><span class="nx">currentIndex</span><span class="p">),</span> +<span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="nx">Y</span><span class="p">[</span><span class="mf">1</span><span class="p">].</span><span class="nx">slice</span><span class="p">(</span><span class="nx">tailLength</span><span class="p">,</span><span class="w"> </span><span class="nx">currentIndex</span><span class="p">),</span> +<span class="w"> </span><span class="nx">mode</span><span class="o">:</span><span class="w"> </span><span class="s1">'lines+markers'</span><span class="p">,</span> +<span class="w"> </span><span class="nx">marker</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">symbol</span><span class="o">:</span><span class="w"> </span><span class="s1">'star'</span><span class="p">,</span> +<span class="w"> </span><span class="nx">size</span><span class="o">:</span><span class="w"> </span><span class="mf">8</span><span class="p">,</span> +<span class="w"> </span><span class="nx">line</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">width</span><span class="o">:</span><span class="w"> </span><span class="mf">0</span><span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="nx">line</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">width</span><span class="o">:</span><span class="w"> </span><span class="mf">2</span><span class="p">,</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="nx">name</span><span class="o">:</span><span class="w"> </span><span class="s1">''</span><span class="p">,</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="nx">X</span><span class="p">[</span><span class="mf">2</span><span class="p">].</span><span class="nx">slice</span><span class="p">(</span><span class="nx">tailLength</span><span class="p">,</span><span class="w"> </span><span class="nx">currentIndex</span><span class="p">),</span> +<span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="nx">Y</span><span class="p">[</span><span class="mf">2</span><span class="p">].</span><span class="nx">slice</span><span class="p">(</span><span class="nx">tailLength</span><span class="p">,</span><span class="w"> </span><span class="nx">currentIndex</span><span class="p">),</span> +<span class="w"> </span><span class="nx">mode</span><span class="o">:</span><span class="w"> </span><span class="s1">'lines+markers'</span><span class="p">,</span> +<span class="w"> </span><span class="nx">marker</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">symbol</span><span class="o">:</span><span class="w"> </span><span class="s1">'star'</span><span class="p">,</span> +<span class="w"> </span><span class="nx">size</span><span class="o">:</span><span class="w"> </span><span class="mf">8</span><span class="p">,</span> +<span class="w"> </span><span class="nx">line</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">width</span><span class="o">:</span><span class="w"> </span><span class="mf">0</span><span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="nx">line</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">width</span><span class="o">:</span><span class="w"> </span><span class="mf">2</span><span class="p">,</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="nx">name</span><span class="o">:</span><span class="w"> </span><span class="s1">''</span><span class="p">,</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="p">];</span> + +<span class="w"> </span><span class="c1">// width: 1000, height: 400</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">layout</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">title</span><span class="o">:</span><span class="w"> </span><span class="s1">'∞ Three-Body Problem: t = '</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">time</span><span class="p">[</span><span class="nx">currentIndex</span><span class="p">].</span><span class="nx">toFixed</span><span class="p">(</span><span class="mf">3</span><span class="p">),</span> +<span class="w"> </span><span class="nx">xaxis</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">title</span><span class="o">:</span><span class="w"> </span><span class="s1">'x'</span><span class="p">,</span> +<span class="w"> </span><span class="nx">range</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="mf">1.1</span><span class="p">,</span><span class="mf">1.1</span><span class="p">]</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="nx">yaxis</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">title</span><span class="o">:</span><span class="w"> </span><span class="s1">'y'</span><span class="p">,</span> +<span class="w"> </span><span class="nx">scaleanchor</span><span class="o">:</span><span class="w"> </span><span class="s1">'x'</span><span class="p">,</span> +<span class="w"> </span><span class="nx">scaleratio</span><span class="o">:</span><span class="w"> </span><span class="mf">1</span><span class="p">,</span> +<span class="w"> </span><span class="nx">range</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="mf">0.5</span><span class="p">,</span><span class="mf">0.5</span><span class="p">]</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="nx">plot_bgcolor</span><span class="o">:</span><span class="w"> </span><span class="s1">'black'</span><span class="p">,</span> +<span class="w"> </span><span class="nx">paper_bgcolor</span><span class="o">:</span><span class="w"> </span><span class="s1">'black'</span><span class="p">,</span> +<span class="w"> </span><span class="nx">font</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">color</span><span class="o">:</span><span class="w"> </span><span class="s1">'white'</span><span class="p">,</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="p">};</span> + +<span class="w"> </span><span class="k">try</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">Plotly</span><span class="p">.</span><span class="nx">animate</span><span class="p">(</span><span class="s2">"plot"</span><span class="p">,</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">data</span><span class="o">:</span><span class="w"> </span><span class="nx">data</span><span class="p">,</span><span class="w"> </span><span class="nx">layout</span><span class="o">:</span><span class="w"> </span><span class="nx">layout</span> +<span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">staticPlot</span><span class="o">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span> +<span class="w"> </span><span class="nx">transition</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">duration</span><span class="o">:</span><span class="w"> </span><span class="mf">0</span><span class="p">,</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="nx">frame</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">duration</span><span class="o">:</span><span class="w"> </span><span class="mf">0</span><span class="p">,</span> +<span class="w"> </span><span class="nx">redraw</span><span class="o">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="p">});</span> +<span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">catch</span><span class="w"> </span><span class="p">(</span><span class="nx">err</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">Plotly</span><span class="p">.</span><span class="nx">newPlot</span><span class="p">(</span><span class="s1">'plot'</span><span class="p">,</span><span class="w"> </span><span class="nx">data</span><span class="p">,</span><span class="w"> </span><span class="nx">layout</span><span class="p">);</span> +<span class="w"> </span><span class="p">}</span> + + +<span class="w"> </span><span class="nx">plotIndex</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="nx">delay</span><span class="p">;</span> +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">plotClassic</span><span class="o">===</span><span class="kc">true</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="k">try</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">requestAnimationFrame</span><span class="p">(</span><span class="nx">plotClassicFunc</span><span class="p">);</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="k">catch</span><span class="w"> </span><span class="p">(</span><span class="nx">err</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="p">}</span> + +<span class="w"> </span><span class="p">}</span> +</code></pre> +</div> <h2>"General" N-Body Solver</h2> <h3>Show me the code!</h3> <div class="codehilite"> -<pre><span></span><code><span class="kd">function</span><span class="w"> </span><span class="nx">step</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">3</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">6.67408313131313e-11</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">k1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaR</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">));</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">k2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaR</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">k1</span><span class="p">,</span><span class="w"> </span><span class="mf">0.5</span><span class="p">)),</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">));</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">k3</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaR</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">k2</span><span class="p">,</span><span class="w"> </span><span class="mf">0.5</span><span class="p">)),</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">));</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">k4</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaR</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">k3</span><span class="p">),</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">));</span><span class="w"></span> - -<span class="w"> </span><span class="nx">coords</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">k1</span><span class="p">,</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="mf">2.0</span><span class="p">,</span><span class="w"> </span><span class="nx">k2</span><span class="p">),</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="mf">2.0</span><span class="p">,</span><span class="w"> </span><span class="nx">k3</span><span class="p">),</span><span class="w"> </span><span class="nx">k4</span><span class="p">),</span><span class="w"> </span><span class="mf">1</span><span class="o">/</span><span class="mf">6</span><span class="p">));</span><span class="w"></span> - -<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="nx">coords</span><span class="p">;</span><span class="w"></span> -<span class="p">}</span><span class="w"></span> - -<span class="kd">function</span><span class="w"> </span><span class="nx">detectCollisionsEscape</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">maxSep</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="p">[</span><span class="nx">x</span><span class="p">,</span><span class="w"> </span><span class="nx">y</span><span class="p">,</span><span class="w"> </span><span class="nx">vx</span><span class="p">,</span><span class="w"> </span><span class="nx">vy</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coords</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">V</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">vx</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">v</span><span class="p">,</span><span class="w"> </span><span class="nx">i</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sqrt</span><span class="p">(</span><span class="nx">v</span><span class="w"> </span><span class="o">**</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">vy</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">**</span><span class="w"> </span><span class="mf">2</span><span class="p">));</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">R</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">V</span><span class="p">.</span><span class="nx">map</span><span class="p">(</span><span class="nx">v</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">v</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">deltaT</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">collision</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w"> </span><span class="nx">collisionInds</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">null</span><span class="p">,</span><span class="w"> </span><span class="nx">escape</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w"> </span><span class="nx">escapeInd</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">null</span><span class="p">;</span><span class="w"></span> - -<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kd">let</span><span class="w"> </span><span class="nx">n</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="nx">n</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">x</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span><span class="w"> </span><span class="nx">n</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">rn</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">R</span><span class="p">[</span><span class="nx">n</span><span class="p">],</span><span class="w"> </span><span class="nx">xn</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">x</span><span class="p">[</span><span class="nx">n</span><span class="p">],</span><span class="w"> </span><span class="nx">yn</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">y</span><span class="p">[</span><span class="nx">n</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kd">let</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">x</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">i</span><span class="w"> </span><span class="o">!==</span><span class="w"> </span><span class="nx">n</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">minSep</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">rn</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">R</span><span class="p">[</span><span class="nx">i</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">sep</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sqrt</span><span class="p">((</span><span class="nx">xn</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">x</span><span class="p">[</span><span class="nx">i</span><span class="p">])</span><span class="w"> </span><span class="o">**</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="p">(</span><span class="nx">yn</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">y</span><span class="p">[</span><span class="nx">i</span><span class="p">])</span><span class="w"> </span><span class="o">**</span><span class="w"> </span><span class="mf">2</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">sep</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">minSep</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="nx">collision</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">true</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="nx">collisionInds</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nx">n</span><span class="p">,</span><span class="w"> </span><span class="nx">i</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">sep</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="nx">maxSep</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="nx">escape</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">true</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="nx">escapeInd</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">n</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="p">[</span><span class="nx">collision</span><span class="p">,</span><span class="w"> </span><span class="nx">collisionInds</span><span class="p">,</span><span class="w"> </span><span class="nx">escape</span><span class="p">,</span><span class="w"> </span><span class="nx">escapeInd</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="p">[</span><span class="nx">collision</span><span class="p">,</span><span class="w"> </span><span class="nx">collisionInds</span><span class="p">,</span><span class="w"> </span><span class="nx">escape</span><span class="p">,</span><span class="w"> </span><span class="nx">escapeInd</span><span class="p">];</span><span class="w"></span> -<span class="p">}</span><span class="w"></span> - -<span class="kd">function</span><span class="w"> </span><span class="nx">nBodyStep</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">maxSep</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">6.67408313131313e-11</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="c1">// Similar to our step function before, but keeping track of collisions</span><span class="w"></span> -<span class="w"> </span><span class="nx">coords</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">step</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">);</span><span class="w"> </span><span class="c1">// Update the positions as we did before</span><span class="w"></span> -<span class="w"> </span><span class="c1">//console.log(detectCollisionsEscape(coords, deltaT, maxSep));</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="p">[</span><span class="nx">collision</span><span class="p">,</span><span class="w"> </span><span class="nx">collisionInds</span><span class="p">,</span><span class="w"> </span><span class="nx">escape</span><span class="p">,</span><span class="w"> </span><span class="nx">escapeInd</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">detectCollisionsEscape</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">maxSep</span><span class="p">);</span><span class="w"> </span><span class="c1">// Detect collisions/escapes</span><span class="w"></span> - - -<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">collision</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="c1">// Do inelastic collision and delete extra body (2 -> 1)</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="p">[</span><span class="nx">i1</span><span class="p">,</span><span class="w"> </span><span class="nx">i2</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">collisionInds</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="p">[</span><span class="nx">x1</span><span class="p">,</span><span class="w"> </span><span class="nx">x2</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nx">coords</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">i1</span><span class="p">],</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">i2</span><span class="p">]];</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="p">[</span><span class="nx">y1</span><span class="p">,</span><span class="w"> </span><span class="nx">y2</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nx">coords</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">i1</span><span class="p">],</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">i2</span><span class="p">]];</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="p">[</span><span class="nx">vx1</span><span class="p">,</span><span class="w"> </span><span class="nx">vx2</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nx">coords</span><span class="p">[</span><span class="mf">2</span><span class="p">][</span><span class="nx">i1</span><span class="p">],</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">2</span><span class="p">][</span><span class="nx">i2</span><span class="p">]];</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="p">[</span><span class="nx">vy1</span><span class="p">,</span><span class="w"> </span><span class="nx">vy2</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nx">coords</span><span class="p">[</span><span class="mf">3</span><span class="p">][</span><span class="nx">i1</span><span class="p">],</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">3</span><span class="p">][</span><span class="nx">i2</span><span class="p">]];</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="p">[</span><span class="nx">px1</span><span class="p">,</span><span class="w"> </span><span class="nx">px2</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nx">masses</span><span class="p">[</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">vx1</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i2</span><span class="p">]</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">vx2</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="p">[</span><span class="nx">py1</span><span class="p">,</span><span class="w"> </span><span class="nx">py2</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nx">masses</span><span class="p">[</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">vy1</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i2</span><span class="p">]</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">vy2</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">px</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">px1</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">px2</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">py</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">py1</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">py2</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">newM</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i2</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">vfx</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">px</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nx">newM</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">vfy</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">py</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nx">newM</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="nx">x1</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">x2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i2</span><span class="p">])</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="p">(</span><span class="nx">masses</span><span class="p">[</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i2</span><span class="p">]);</span><span class="w"> </span><span class="c1">// Center of mass</span><span class="w"></span> -<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="nx">y1</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">y2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i2</span><span class="p">])</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="p">(</span><span class="nx">masses</span><span class="p">[</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i2</span><span class="p">]);</span><span class="w"></span> -<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">2</span><span class="p">][</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">vfx</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">3</span><span class="p">][</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">vfy</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">0</span><span class="p">].</span><span class="nx">splice</span><span class="p">(</span><span class="nx">i2</span><span class="p">,</span><span class="w"> </span><span class="mf">1</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">1</span><span class="p">].</span><span class="nx">splice</span><span class="p">(</span><span class="nx">i2</span><span class="p">,</span><span class="w"> </span><span class="mf">1</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">2</span><span class="p">].</span><span class="nx">splice</span><span class="p">(</span><span class="nx">i2</span><span class="p">,</span><span class="w"> </span><span class="mf">1</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">3</span><span class="p">].</span><span class="nx">splice</span><span class="p">(</span><span class="nx">i2</span><span class="p">,</span><span class="w"> </span><span class="mf">1</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">newM</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="nx">masses</span><span class="p">.</span><span class="nx">splice</span><span class="p">(</span><span class="nx">i2</span><span class="p">,</span><span class="w"> </span><span class="mf">1</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="nx">nBodies</span><span class="o">--</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="w"> </span><span class="c1">// Could also implement condition for escape where we stop calculating forces but I'm too lazy for now</span><span class="w"></span> -<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="p">[</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">collision</span><span class="p">,</span><span class="w"> </span><span class="nx">collisionInds</span><span class="p">,</span><span class="w"> </span><span class="nx">escape</span><span class="p">,</span><span class="w"> </span><span class="nx">escapeInd</span><span class="p">];</span><span class="w"></span> -<span class="p">}</span><span class="w"></span> - -<span class="kd">function</span><span class="w"> </span><span class="nx">uniform</span><span class="p">(</span><span class="nx">min</span><span class="p">,</span><span class="w"> </span><span class="nx">max</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">random</span><span class="p">()</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="p">(</span><span class="nx">max</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">min</span><span class="p">)</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">min</span><span class="p">;</span><span class="w"></span> -<span class="p">}</span><span class="w"></span> - -<span class="kd">function</span><span class="w"> </span><span class="nx">deepCopyCoordsArray</span><span class="p">(</span><span class="nx">arr</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="nx">arr</span><span class="p">.</span><span class="nx">map</span><span class="p">(</span><span class="nx">innerArr</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">innerArr</span><span class="p">.</span><span class="nx">slice</span><span class="p">());</span><span class="w"></span> -<span class="p">}</span><span class="w"></span> - -<span class="kd">function</span><span class="w"> </span><span class="nx">genNBodyResults</span><span class="p">(</span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">tStop</span><span class="p">,</span><span class="w"> </span><span class="nx">nTPts</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodiesStop</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">10</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">6.67408313131313e-11</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">btn</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s2">"startSim3"</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="c1">// Set button text to Solving</span><span class="w"></span> -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">prevText</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">btn</span><span class="p">.</span><span class="nx">innerHTML</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="nx">btn</span><span class="p">.</span><span class="nx">innerHTML</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"Solving..."</span><span class="p">;</span><span class="w"></span> - -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">coords</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nb">Array</span><span class="p">(</span><span class="nx">nBodies</span><span class="p">).</span><span class="nx">fill</span><span class="p">(</span><span class="mf">0</span><span class="p">),</span><span class="w"> </span><span class="nb">Array</span><span class="p">(</span><span class="nx">nBodies</span><span class="p">).</span><span class="nx">fill</span><span class="p">(</span><span class="mf">0</span><span class="p">),</span><span class="w"> </span><span class="nb">Array</span><span class="p">(</span><span class="nx">nBodies</span><span class="p">).</span><span class="nx">fill</span><span class="p">(</span><span class="mf">0</span><span class="p">),</span><span class="w"> </span><span class="nb">Array</span><span class="p">(</span><span class="nx">nBodies</span><span class="p">).</span><span class="nx">fill</span><span class="p">(</span><span class="mf">0</span><span class="p">)];</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">Mstar</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">2e30</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">Mp</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">Mstar</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">1e4</span><span class="p">;</span><span class="w"></span> - -<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kd">let</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="c1">// Initialize coordinates on ~Keplerian orbits</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">accept</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">false</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">r</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">null</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="k">while</span><span class="w"> </span><span class="p">(</span><span class="o">!</span><span class="nx">accept</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="c1">// Prevent a particle from spawning within 0.2 AU too close to "star"</span><span class="w"></span> -<span class="w"> </span><span class="nx">r</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">random</span><span class="p">()</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">1.5e11</span><span class="p">;</span><span class="w"> </span><span class="c1">// Say radius of 2 AU</span><span class="w"></span> -<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">r</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">1.5e11</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="mf">0.2</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="nx">accept</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">true</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">theta</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">uniform</span><span class="p">(</span><span class="mf">0</span><span class="p">,</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">PI</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">r</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">cos</span><span class="p">(</span><span class="nx">theta</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">y</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">r</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sin</span><span class="p">(</span><span class="nx">theta</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">v</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sqrt</span><span class="p">(</span><span class="nx">G</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">Mstar</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nx">r</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">perturbedV</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">v</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">v</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">1000</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">uniform</span><span class="p">(</span><span class="o">-</span><span class="mf">1</span><span class="p">,</span><span class="w"> </span><span class="mf">1</span><span class="p">);</span><span class="w"> </span><span class="c1">// Perturb the velocities ever so slightly</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">vTheta</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">atan2</span><span class="p">(</span><span class="nx">y</span><span class="p">,</span><span class="w"> </span><span class="nx">x</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">x</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">y</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">2</span><span class="p">][</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">-</span><span class="nx">perturbedV</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sin</span><span class="p">(</span><span class="nx">vTheta</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">3</span><span class="p">][</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">perturbedV</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">cos</span><span class="p">(</span><span class="nx">vTheta</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> - -<span class="w"> </span><span class="c1">//console.log('Initial coords:', coords);</span><span class="w"></span> - - -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">masses</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Array</span><span class="p">(</span><span class="nx">nBodies</span><span class="p">).</span><span class="nx">fill</span><span class="p">(</span><span class="nx">Mp</span><span class="p">);</span><span class="w"> </span><span class="c1">// Initialize masses</span><span class="w"></span> -<span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">Mstar</span><span class="p">;</span><span class="w"> </span><span class="c1">// Make index one special as the central star</span><span class="w"></span> -<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">2</span><span class="p">][</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">3</span><span class="p">][</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="c1">// Initialize central star at origin with no velocity</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">yearSec</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">365</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">24</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">3600</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">time</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Array</span><span class="p">.</span><span class="kr">from</span><span class="p">({</span><span class="w"> </span><span class="nx">length</span><span class="o">:</span><span class="w"> </span><span class="nx">nTPts</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="p">(</span><span class="nx">_</span><span class="p">,</span><span class="w"> </span><span class="nx">i</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">tStop</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="p">(</span><span class="nx">nTPts</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mf">1</span><span class="p">)</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">yearSec</span><span class="p">);</span><span class="w"> </span><span class="c1">// Years -> s</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">t</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">time</span><span class="p">[</span><span class="mf">0</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">deltaT</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">time</span><span class="p">[</span><span class="mf">1</span><span class="p">]</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">time</span><span class="p">[</span><span class="mf">0</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">tInd</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">coordsRecord</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nx">deepCopyCoordsArray</span><span class="p">(</span><span class="nx">coords</span><span class="p">)];</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">massRecord</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nx">masses</span><span class="p">.</span><span class="nx">slice</span><span class="p">()];</span><span class="w"> </span><span class="c1">// Initialize records with initial conditions</span><span class="w"></span> - - -<span class="w"> </span><span class="k">while</span><span class="w"> </span><span class="p">(</span><span class="nx">tInd</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">nTPts</span><span class="w"> </span><span class="o">&&</span><span class="w"> </span><span class="nx">nBodies</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="nx">nBodiesStop</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="c1">//console.log('Initial coords:', coords);</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">nBodyStep</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="mf">10</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">1.5e11</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">);</span><span class="w"> </span><span class="c1">// Update</span><span class="w"></span> -<span class="w"> </span><span class="nx">coordsRecord</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">deepCopyCoordsArray</span><span class="p">(</span><span class="nx">coords</span><span class="p">));</span><span class="w"></span> -<span class="w"> </span><span class="nx">massRecord</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">masses</span><span class="p">.</span><span class="nx">slice</span><span class="p">());</span><span class="w"> </span><span class="c1">// Add to records</span><span class="w"></span> -<span class="w"> </span><span class="nx">tInd</span><span class="o">++</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="nx">t</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">time</span><span class="p">[</span><span class="nx">tInd</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="c1">//console.log(`currently at t = ${(t / yearSec).toFixed(2)} years\r`);</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="w"> </span><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="sb">`final time = </span><span class="si">${</span><span class="nx">time</span><span class="p">[</span><span class="nx">tInd</span><span class="p">]</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nx">yearSec</span><span class="si">}</span><span class="sb"> years with </span><span class="si">${</span><span class="nx">nBodies</span><span class="si">}</span><span class="sb"> bodies remaining`</span><span class="p">);</span><span class="w"></span> - -<span class="w"> </span><span class="c1">// Set button text to Start Simulation</span><span class="w"></span> -<span class="w"> </span><span class="nx">btn</span><span class="p">.</span><span class="nx">innerHTML</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">prevText</span><span class="p">;</span><span class="w"></span> - -<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="p">[</span><span class="nx">coordsRecord</span><span class="p">,</span><span class="w"> </span><span class="nx">massRecord</span><span class="p">,</span><span class="w"> </span><span class="nx">time</span><span class="p">.</span><span class="nx">slice</span><span class="p">(</span><span class="mf">0</span><span class="p">,</span><span class="w"> </span><span class="nx">tInd</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mf">1</span><span class="p">)];</span><span class="w"></span> -<span class="p">}</span><span class="w"></span> - - -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="p">[</span><span class="nx">coordsRecordR</span><span class="p">,</span><span class="w"> </span><span class="nx">_</span><span class="p">,</span><span class="w"> </span><span class="nx">tR</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">genNBodyResults</span><span class="p">(</span><span class="mf">256</span><span class="p">,</span><span class="mf">1</span><span class="p">,</span><span class="mf">1001</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="c1">//console.log(coordsRecordR);</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">yearSec</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">365</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">24</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">3600</span><span class="p">;</span><span class="w"></span> - -<span class="w"> </span><span class="kd">function</span><span class="w"> </span><span class="nx">createFrame</span><span class="p">(</span><span class="nx">coordsR</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="o">!</span><span class="nx">coordsR</span><span class="w"> </span><span class="o">||</span><span class="w"> </span><span class="o">!</span><span class="nx">coordsR</span><span class="p">[</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">||</span><span class="w"> </span><span class="o">!</span><span class="nx">coordsR</span><span class="p">[</span><span class="mf">1</span><span class="p">])</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="p">[];</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> - -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">traceCentralStar</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="nx">coordsR</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">1.5e11</span><span class="p">],</span><span class="w"></span> -<span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="nx">coordsR</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">1.5e11</span><span class="p">],</span><span class="w"></span> -<span class="w"> </span><span class="nx">mode</span><span class="o">:</span><span class="w"> </span><span class="s1">'markers'</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="nx">type</span><span class="o">:</span><span class="w"> </span><span class="s1">'scatter'</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="nx">name</span><span class="o">:</span><span class="w"> </span><span class="s1">'Central star'</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="nx">marker</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">color</span><span class="o">:</span><span class="w"> </span><span class="s1">'gold'</span><span class="p">,</span><span class="w"> </span><span class="nx">symbol</span><span class="o">:</span><span class="w"> </span><span class="s1">'star'</span><span class="p">,</span><span class="w"> </span><span class="nx">size</span><span class="o">:</span><span class="w"> </span><span class="mf">10</span><span class="w"> </span><span class="p">},</span><span class="w"></span> -<span class="w"> </span><span class="p">};</span><span class="w"></span> - -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">xCoords</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coordsR</span><span class="p">[</span><span class="mf">0</span><span class="p">].</span><span class="nx">slice</span><span class="p">(</span><span class="mf">1</span><span class="p">).</span><span class="nx">map</span><span class="p">(</span><span class="nx">x</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">x</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">1.5e11</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">yCoords</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coordsR</span><span class="p">[</span><span class="mf">1</span><span class="p">].</span><span class="nx">slice</span><span class="p">(</span><span class="mf">1</span><span class="p">).</span><span class="nx">map</span><span class="p">(</span><span class="nx">y</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">y</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">1.5e11</span><span class="p">);</span><span class="w"></span> - -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">traceOtherBodies</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="nx">xCoords</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="nx">yCoords</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="nx">mode</span><span class="o">:</span><span class="w"> </span><span class="s1">'markers'</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="nx">type</span><span class="o">:</span><span class="w"> </span><span class="s1">'scatter'</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="nx">name</span><span class="o">:</span><span class="w"> </span><span class="s1">''</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="nx">marker</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">color</span><span class="o">:</span><span class="w"> </span><span class="s1">'dodgerblue'</span><span class="p">,</span><span class="w"> </span><span class="nx">symbol</span><span class="o">:</span><span class="w"> </span><span class="s1">'circle'</span><span class="p">,</span><span class="w"> </span><span class="nx">size</span><span class="o">:</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="p">},</span><span class="w"></span> -<span class="w"> </span><span class="p">};</span><span class="w"></span> - -<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="p">[</span><span class="nx">traceCentralStar</span><span class="p">,</span><span class="w"> </span><span class="nx">traceOtherBodies</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> - - -<span class="w"> </span><span class="kd">function</span><span class="w"> </span><span class="nx">createLayout</span><span class="p">(</span><span class="nx">i</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="nx">title</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="nx">text</span><span class="o">:</span><span class="w"> </span><span class="sb">`N-Body Problem: t = </span><span class="si">${</span><span class="nb">Number</span><span class="p">(</span><span class="nx">t</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nx">yearSec</span><span class="p">).</span><span class="nx">toFixed</span><span class="p">(</span><span class="mf">3</span><span class="p">)</span><span class="si">}</span><span class="sb"> years`</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="mf">0.03</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="mf">0.97</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="nx">xanchor</span><span class="o">:</span><span class="w"> </span><span class="s1">'left'</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="nx">yanchor</span><span class="o">:</span><span class="w"> </span><span class="s1">'top'</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="nx">font</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">size</span><span class="o">:</span><span class="w"> </span><span class="mf">14</span><span class="w"> </span><span class="p">},</span><span class="w"></span> -<span class="w"> </span><span class="p">},</span><span class="w"></span> -<span class="w"> </span><span class="nx">xaxis</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">title</span><span class="o">:</span><span class="w"> </span><span class="s1">'x [AU]'</span><span class="p">,</span><span class="w"> </span><span class="nx">range</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="mf">2.1</span><span class="p">,</span><span class="w"> </span><span class="mf">2.1</span><span class="p">]</span><span class="w"> </span><span class="p">},</span><span class="w"></span> -<span class="w"> </span><span class="nx">yaxis</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">title</span><span class="o">:</span><span class="w"> </span><span class="s1">'y [AU]'</span><span class="p">,</span><span class="w"> </span><span class="nx">range</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="mf">2.1</span><span class="p">,</span><span class="w"> </span><span class="mf">2.1</span><span class="p">],</span><span class="w"> </span><span class="nx">scaleanchor</span><span class="o">:</span><span class="w"> </span><span class="s1">'x'</span><span class="p">,</span><span class="w"> </span><span class="nx">scaleratio</span><span class="o">:</span><span class="w"> </span><span class="mf">1</span><span class="w"> </span><span class="p">},</span><span class="w"></span> -<span class="w"> </span><span class="nx">showlegend</span><span class="o">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="nx">margin</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">l</span><span class="o">:</span><span class="w"> </span><span class="mf">60</span><span class="p">,</span><span class="w"> </span><span class="nx">r</span><span class="o">:</span><span class="w"> </span><span class="mf">40</span><span class="p">,</span><span class="w"> </span><span class="nx">t</span><span class="o">:</span><span class="w"> </span><span class="mf">40</span><span class="p">,</span><span class="w"> </span><span class="nx">b</span><span class="o">:</span><span class="w"> </span><span class="mf">40</span><span class="w"> </span><span class="p">},</span><span class="w"></span> -<span class="w"> </span><span class="nx">width</span><span class="o">:</span><span class="w"> </span><span class="mf">800</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="nx">height</span><span class="o">:</span><span class="w"> </span><span class="mf">800</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="nx">plot_bgcolor</span><span class="o">:</span><span class="w"> </span><span class="s1">'black'</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="p">};</span><span class="w"></span> -<span class="p">}</span><span class="w"></span> - -<span class="w"> </span><span class="kd">function</span><span class="w"> </span><span class="nx">animateNBodyProblem</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">nFrames</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">tR</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span><span class="w"></span> - -<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kd">let</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">nFrames</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">frameData</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">createFrame</span><span class="p">(</span><span class="nx">coordsRecordR</span><span class="p">[</span><span class="nx">i</span><span class="p">]);</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">layout</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">createLayout</span><span class="p">(</span><span class="nx">i</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="c1">//Plotly.newPlot(plotDiv, frameData, layout);</span><span class="w"></span> -<span class="w"> </span><span class="k">try</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="nx">Plotly</span><span class="p">.</span><span class="nx">animate</span><span class="p">(</span><span class="s2">"plot"</span><span class="p">,</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="nx">data</span><span class="o">:</span><span class="w"> </span><span class="nx">frameData</span><span class="p">,</span><span class="w"> </span><span class="nx">layout</span><span class="o">:</span><span class="w"> </span><span class="nx">layout</span><span class="w"></span> -<span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="nx">staticPlot</span><span class="o">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="nx">transition</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="nx">duration</span><span class="o">:</span><span class="w"> </span><span class="mf">0</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="p">},</span><span class="w"></span> -<span class="w"> </span><span class="nx">frame</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="nx">duration</span><span class="o">:</span><span class="w"> </span><span class="mf">0</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="nx">redraw</span><span class="o">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="w"> </span><span class="p">});</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">catch</span><span class="w"> </span><span class="p">(</span><span class="nx">err</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="nx">Plotly</span><span class="p">.</span><span class="nx">newPlot</span><span class="p">(</span><span class="s1">'plot'</span><span class="p">,</span><span class="w"> </span><span class="nx">frameData</span><span class="p">,</span><span class="w"> </span><span class="nx">layout</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="p">}</span><span class="w"></span> - -<span class="nx">animateNBodyProblem</span><span class="p">();</span><span class="w"></span> +<pre><span></span><code><span class="kd">function</span><span class="w"> </span><span class="nx">step</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">3</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">6.67408313131313e-11</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">k1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaR</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">));</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">k2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaR</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">k1</span><span class="p">,</span><span class="w"> </span><span class="mf">0.5</span><span class="p">)),</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">));</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">k3</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaR</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">k2</span><span class="p">,</span><span class="w"> </span><span class="mf">0.5</span><span class="p">)),</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">));</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">k4</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaR</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">k3</span><span class="p">),</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">));</span> + +<span class="w"> </span><span class="nx">coords</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">k1</span><span class="p">,</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="mf">2.0</span><span class="p">,</span><span class="w"> </span><span class="nx">k2</span><span class="p">),</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="mf">2.0</span><span class="p">,</span><span class="w"> </span><span class="nx">k3</span><span class="p">),</span><span class="w"> </span><span class="nx">k4</span><span class="p">),</span><span class="w"> </span><span class="mf">1</span><span class="o">/</span><span class="mf">6</span><span class="p">));</span> + +<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="nx">coords</span><span class="p">;</span> +<span class="p">}</span> + +<span class="kd">function</span><span class="w"> </span><span class="nx">detectCollisionsEscape</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">maxSep</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="p">[</span><span class="nx">x</span><span class="p">,</span><span class="w"> </span><span class="nx">y</span><span class="p">,</span><span class="w"> </span><span class="nx">vx</span><span class="p">,</span><span class="w"> </span><span class="nx">vy</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coords</span><span class="p">;</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">V</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">vx</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">v</span><span class="p">,</span><span class="w"> </span><span class="nx">i</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sqrt</span><span class="p">(</span><span class="nx">v</span><span class="w"> </span><span class="o">**</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">vy</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">**</span><span class="w"> </span><span class="mf">2</span><span class="p">));</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">R</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">V</span><span class="p">.</span><span class="nx">map</span><span class="p">(</span><span class="nx">v</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">v</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">deltaT</span><span class="p">);</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">collision</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w"> </span><span class="nx">collisionInds</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">null</span><span class="p">,</span><span class="w"> </span><span class="nx">escape</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w"> </span><span class="nx">escapeInd</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">null</span><span class="p">;</span> + +<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kd">let</span><span class="w"> </span><span class="nx">n</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="nx">n</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">x</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span><span class="w"> </span><span class="nx">n</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">rn</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">R</span><span class="p">[</span><span class="nx">n</span><span class="p">],</span><span class="w"> </span><span class="nx">xn</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">x</span><span class="p">[</span><span class="nx">n</span><span class="p">],</span><span class="w"> </span><span class="nx">yn</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">y</span><span class="p">[</span><span class="nx">n</span><span class="p">];</span> +<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kd">let</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">x</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">i</span><span class="w"> </span><span class="o">!==</span><span class="w"> </span><span class="nx">n</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">minSep</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">rn</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">R</span><span class="p">[</span><span class="nx">i</span><span class="p">];</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">sep</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sqrt</span><span class="p">((</span><span class="nx">xn</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">x</span><span class="p">[</span><span class="nx">i</span><span class="p">])</span><span class="w"> </span><span class="o">**</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="p">(</span><span class="nx">yn</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">y</span><span class="p">[</span><span class="nx">i</span><span class="p">])</span><span class="w"> </span><span class="o">**</span><span class="w"> </span><span class="mf">2</span><span class="p">);</span> +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">sep</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">minSep</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">collision</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">true</span><span class="p">;</span> +<span class="w"> </span><span class="nx">collisionInds</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nx">n</span><span class="p">,</span><span class="w"> </span><span class="nx">i</span><span class="p">];</span> +<span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">sep</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="nx">maxSep</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">escape</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">true</span><span class="p">;</span> +<span class="w"> </span><span class="nx">escapeInd</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">n</span><span class="p">;</span> +<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="p">[</span><span class="nx">collision</span><span class="p">,</span><span class="w"> </span><span class="nx">collisionInds</span><span class="p">,</span><span class="w"> </span><span class="nx">escape</span><span class="p">,</span><span class="w"> </span><span class="nx">escapeInd</span><span class="p">];</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="p">[</span><span class="nx">collision</span><span class="p">,</span><span class="w"> </span><span class="nx">collisionInds</span><span class="p">,</span><span class="w"> </span><span class="nx">escape</span><span class="p">,</span><span class="w"> </span><span class="nx">escapeInd</span><span class="p">];</span> +<span class="p">}</span> + +<span class="kd">function</span><span class="w"> </span><span class="nx">nBodyStep</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">maxSep</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">6.67408313131313e-11</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="c1">// Similar to our step function before, but keeping track of collisions</span> +<span class="w"> </span><span class="nx">coords</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">step</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">);</span><span class="w"> </span><span class="c1">// Update the positions as we did before</span> +<span class="w"> </span><span class="c1">//console.log(detectCollisionsEscape(coords, deltaT, maxSep));</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="p">[</span><span class="nx">collision</span><span class="p">,</span><span class="w"> </span><span class="nx">collisionInds</span><span class="p">,</span><span class="w"> </span><span class="nx">escape</span><span class="p">,</span><span class="w"> </span><span class="nx">escapeInd</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">detectCollisionsEscape</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">maxSep</span><span class="p">);</span><span class="w"> </span><span class="c1">// Detect collisions/escapes</span> + + +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">collision</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="c1">// Do inelastic collision and delete extra body (2 -> 1)</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="p">[</span><span class="nx">i1</span><span class="p">,</span><span class="w"> </span><span class="nx">i2</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">collisionInds</span><span class="p">;</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="p">[</span><span class="nx">x1</span><span class="p">,</span><span class="w"> </span><span class="nx">x2</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nx">coords</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">i1</span><span class="p">],</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">i2</span><span class="p">]];</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="p">[</span><span class="nx">y1</span><span class="p">,</span><span class="w"> </span><span class="nx">y2</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nx">coords</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">i1</span><span class="p">],</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">i2</span><span class="p">]];</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="p">[</span><span class="nx">vx1</span><span class="p">,</span><span class="w"> </span><span class="nx">vx2</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nx">coords</span><span class="p">[</span><span class="mf">2</span><span class="p">][</span><span class="nx">i1</span><span class="p">],</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">2</span><span class="p">][</span><span class="nx">i2</span><span class="p">]];</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="p">[</span><span class="nx">vy1</span><span class="p">,</span><span class="w"> </span><span class="nx">vy2</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nx">coords</span><span class="p">[</span><span class="mf">3</span><span class="p">][</span><span class="nx">i1</span><span class="p">],</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">3</span><span class="p">][</span><span class="nx">i2</span><span class="p">]];</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="p">[</span><span class="nx">px1</span><span class="p">,</span><span class="w"> </span><span class="nx">px2</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nx">masses</span><span class="p">[</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">vx1</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i2</span><span class="p">]</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">vx2</span><span class="p">];</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="p">[</span><span class="nx">py1</span><span class="p">,</span><span class="w"> </span><span class="nx">py2</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nx">masses</span><span class="p">[</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">vy1</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i2</span><span class="p">]</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">vy2</span><span class="p">];</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">px</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">px1</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">px2</span><span class="p">;</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">py</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">py1</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">py2</span><span class="p">;</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">newM</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i2</span><span class="p">];</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">vfx</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">px</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nx">newM</span><span class="p">;</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">vfy</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">py</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nx">newM</span><span class="p">;</span> +<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="nx">x1</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">x2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i2</span><span class="p">])</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="p">(</span><span class="nx">masses</span><span class="p">[</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i2</span><span class="p">]);</span><span class="w"> </span><span class="c1">// Center of mass</span> +<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="nx">y1</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">y2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i2</span><span class="p">])</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="p">(</span><span class="nx">masses</span><span class="p">[</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i2</span><span class="p">]);</span> +<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">2</span><span class="p">][</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">vfx</span><span class="p">;</span> +<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">3</span><span class="p">][</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">vfy</span><span class="p">;</span> +<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">0</span><span class="p">].</span><span class="nx">splice</span><span class="p">(</span><span class="nx">i2</span><span class="p">,</span><span class="w"> </span><span class="mf">1</span><span class="p">);</span> +<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">1</span><span class="p">].</span><span class="nx">splice</span><span class="p">(</span><span class="nx">i2</span><span class="p">,</span><span class="w"> </span><span class="mf">1</span><span class="p">);</span> +<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">2</span><span class="p">].</span><span class="nx">splice</span><span class="p">(</span><span class="nx">i2</span><span class="p">,</span><span class="w"> </span><span class="mf">1</span><span class="p">);</span> +<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">3</span><span class="p">].</span><span class="nx">splice</span><span class="p">(</span><span class="nx">i2</span><span class="p">,</span><span class="w"> </span><span class="mf">1</span><span class="p">);</span> +<span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">newM</span><span class="p">;</span> +<span class="w"> </span><span class="nx">masses</span><span class="p">.</span><span class="nx">splice</span><span class="p">(</span><span class="nx">i2</span><span class="p">,</span><span class="w"> </span><span class="mf">1</span><span class="p">);</span> +<span class="w"> </span><span class="nx">nBodies</span><span class="o">--</span><span class="p">;</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="c1">// Could also implement condition for escape where we stop calculating forces but I'm too lazy for now</span> +<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="p">[</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">collision</span><span class="p">,</span><span class="w"> </span><span class="nx">collisionInds</span><span class="p">,</span><span class="w"> </span><span class="nx">escape</span><span class="p">,</span><span class="w"> </span><span class="nx">escapeInd</span><span class="p">];</span> +<span class="p">}</span> + +<span class="kd">function</span><span class="w"> </span><span class="nx">uniform</span><span class="p">(</span><span class="nx">min</span><span class="p">,</span><span class="w"> </span><span class="nx">max</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">random</span><span class="p">()</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="p">(</span><span class="nx">max</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">min</span><span class="p">)</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">min</span><span class="p">;</span> +<span class="p">}</span> + +<span class="kd">function</span><span class="w"> </span><span class="nx">deepCopyCoordsArray</span><span class="p">(</span><span class="nx">arr</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="nx">arr</span><span class="p">.</span><span class="nx">map</span><span class="p">(</span><span class="nx">innerArr</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">innerArr</span><span class="p">.</span><span class="nx">slice</span><span class="p">());</span> +<span class="p">}</span> + +<span class="kd">function</span><span class="w"> </span><span class="nx">genNBodyResults</span><span class="p">(</span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">tStop</span><span class="p">,</span><span class="w"> </span><span class="nx">nTPts</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodiesStop</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">10</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">6.67408313131313e-11</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> + +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">btn</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s2">"startSim3"</span><span class="p">);</span> +<span class="w"> </span><span class="c1">// Set button text to Solving</span> +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">prevText</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">btn</span><span class="p">.</span><span class="nx">innerHTML</span><span class="p">;</span> +<span class="w"> </span><span class="nx">btn</span><span class="p">.</span><span class="nx">innerHTML</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"Solving..."</span><span class="p">;</span> + +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">coords</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nb">Array</span><span class="p">(</span><span class="nx">nBodies</span><span class="p">).</span><span class="nx">fill</span><span class="p">(</span><span class="mf">0</span><span class="p">),</span><span class="w"> </span><span class="nb">Array</span><span class="p">(</span><span class="nx">nBodies</span><span class="p">).</span><span class="nx">fill</span><span class="p">(</span><span class="mf">0</span><span class="p">),</span><span class="w"> </span><span class="nb">Array</span><span class="p">(</span><span class="nx">nBodies</span><span class="p">).</span><span class="nx">fill</span><span class="p">(</span><span class="mf">0</span><span class="p">),</span><span class="w"> </span><span class="nb">Array</span><span class="p">(</span><span class="nx">nBodies</span><span class="p">).</span><span class="nx">fill</span><span class="p">(</span><span class="mf">0</span><span class="p">)];</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">Mstar</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">2e30</span><span class="p">;</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">Mp</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">Mstar</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">1e4</span><span class="p">;</span> + +<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kd">let</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="c1">// Initialize coordinates on ~Keplerian orbits</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">accept</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">false</span><span class="p">;</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">r</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">null</span><span class="p">;</span> +<span class="w"> </span><span class="k">while</span><span class="w"> </span><span class="p">(</span><span class="o">!</span><span class="nx">accept</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="c1">// Prevent a particle from spawning within 0.2 AU too close to "star"</span> +<span class="w"> </span><span class="nx">r</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">random</span><span class="p">()</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">1.5e11</span><span class="p">;</span><span class="w"> </span><span class="c1">// Say radius of 2 AU</span> +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">r</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">1.5e11</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="mf">0.2</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">accept</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">true</span><span class="p">;</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">theta</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">uniform</span><span class="p">(</span><span class="mf">0</span><span class="p">,</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">PI</span><span class="p">);</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">r</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">cos</span><span class="p">(</span><span class="nx">theta</span><span class="p">);</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">y</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">r</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sin</span><span class="p">(</span><span class="nx">theta</span><span class="p">);</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">v</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sqrt</span><span class="p">(</span><span class="nx">G</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">Mstar</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nx">r</span><span class="p">);</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">perturbedV</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">v</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">v</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">1000</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">uniform</span><span class="p">(</span><span class="o">-</span><span class="mf">1</span><span class="p">,</span><span class="w"> </span><span class="mf">1</span><span class="p">);</span><span class="w"> </span><span class="c1">// Perturb the velocities ever so slightly</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">vTheta</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">atan2</span><span class="p">(</span><span class="nx">y</span><span class="p">,</span><span class="w"> </span><span class="nx">x</span><span class="p">);</span> +<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">x</span><span class="p">;</span> +<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">y</span><span class="p">;</span> +<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">2</span><span class="p">][</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">-</span><span class="nx">perturbedV</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sin</span><span class="p">(</span><span class="nx">vTheta</span><span class="p">);</span> +<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">3</span><span class="p">][</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">perturbedV</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">cos</span><span class="p">(</span><span class="nx">vTheta</span><span class="p">);</span> +<span class="w"> </span><span class="p">}</span> + +<span class="w"> </span><span class="c1">//console.log('Initial coords:', coords);</span> + + +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">masses</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Array</span><span class="p">(</span><span class="nx">nBodies</span><span class="p">).</span><span class="nx">fill</span><span class="p">(</span><span class="nx">Mp</span><span class="p">);</span><span class="w"> </span><span class="c1">// Initialize masses</span> +<span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">Mstar</span><span class="p">;</span><span class="w"> </span><span class="c1">// Make index one special as the central star</span> +<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span> +<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span> +<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">2</span><span class="p">][</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span> +<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">3</span><span class="p">][</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="c1">// Initialize central star at origin with no velocity</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">yearSec</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">365</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">24</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">3600</span><span class="p">;</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">time</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Array</span><span class="p">.</span><span class="kr">from</span><span class="p">({</span><span class="w"> </span><span class="nx">length</span><span class="o">:</span><span class="w"> </span><span class="nx">nTPts</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="p">(</span><span class="nx">_</span><span class="p">,</span><span class="w"> </span><span class="nx">i</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">tStop</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="p">(</span><span class="nx">nTPts</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mf">1</span><span class="p">)</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">yearSec</span><span class="p">);</span><span class="w"> </span><span class="c1">// Years -> s</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">t</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">time</span><span class="p">[</span><span class="mf">0</span><span class="p">];</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">deltaT</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">time</span><span class="p">[</span><span class="mf">1</span><span class="p">]</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">time</span><span class="p">[</span><span class="mf">0</span><span class="p">];</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">tInd</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">coordsRecord</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nx">deepCopyCoordsArray</span><span class="p">(</span><span class="nx">coords</span><span class="p">)];</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">massRecord</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nx">masses</span><span class="p">.</span><span class="nx">slice</span><span class="p">()];</span><span class="w"> </span><span class="c1">// Initialize records with initial conditions</span> + + +<span class="w"> </span><span class="k">while</span><span class="w"> </span><span class="p">(</span><span class="nx">tInd</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">nTPts</span><span class="w"> </span><span class="o">&&</span><span class="w"> </span><span class="nx">nBodies</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="nx">nBodiesStop</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="c1">//console.log('Initial coords:', coords);</span> +<span class="w"> </span><span class="p">[</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">nBodyStep</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="mf">10</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">1.5e11</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">);</span><span class="w"> </span><span class="c1">// Update</span> +<span class="w"> </span><span class="nx">coordsRecord</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">deepCopyCoordsArray</span><span class="p">(</span><span class="nx">coords</span><span class="p">));</span> +<span class="w"> </span><span class="nx">massRecord</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">masses</span><span class="p">.</span><span class="nx">slice</span><span class="p">());</span><span class="w"> </span><span class="c1">// Add to records</span> +<span class="w"> </span><span class="nx">tInd</span><span class="o">++</span><span class="p">;</span> +<span class="w"> </span><span class="nx">t</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">time</span><span class="p">[</span><span class="nx">tInd</span><span class="p">];</span> +<span class="w"> </span><span class="c1">//console.log(`currently at t = ${(t / yearSec).toFixed(2)} years\r`);</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="sb">`final time = </span><span class="si">${</span><span class="nx">time</span><span class="p">[</span><span class="nx">tInd</span><span class="p">]</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nx">yearSec</span><span class="si">}</span><span class="sb"> years with </span><span class="si">${</span><span class="nx">nBodies</span><span class="si">}</span><span class="sb"> bodies remaining`</span><span class="p">);</span> + +<span class="w"> </span><span class="c1">// Set button text to Start Simulation</span> +<span class="w"> </span><span class="nx">btn</span><span class="p">.</span><span class="nx">innerHTML</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">prevText</span><span class="p">;</span> + +<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="p">[</span><span class="nx">coordsRecord</span><span class="p">,</span><span class="w"> </span><span class="nx">massRecord</span><span class="p">,</span><span class="w"> </span><span class="nx">time</span><span class="p">.</span><span class="nx">slice</span><span class="p">(</span><span class="mf">0</span><span class="p">,</span><span class="w"> </span><span class="nx">tInd</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mf">1</span><span class="p">)];</span> +<span class="p">}</span> + + +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="p">[</span><span class="nx">coordsRecordR</span><span class="p">,</span><span class="w"> </span><span class="nx">_</span><span class="p">,</span><span class="w"> </span><span class="nx">tR</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">genNBodyResults</span><span class="p">(</span><span class="mf">256</span><span class="p">,</span><span class="mf">1</span><span class="p">,</span><span class="mf">1001</span><span class="p">);</span> +<span class="w"> </span><span class="c1">//console.log(coordsRecordR);</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">yearSec</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">365</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">24</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">3600</span><span class="p">;</span> + +<span class="w"> </span><span class="kd">function</span><span class="w"> </span><span class="nx">createFrame</span><span class="p">(</span><span class="nx">coordsR</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="o">!</span><span class="nx">coordsR</span><span class="w"> </span><span class="o">||</span><span class="w"> </span><span class="o">!</span><span class="nx">coordsR</span><span class="p">[</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">||</span><span class="w"> </span><span class="o">!</span><span class="nx">coordsR</span><span class="p">[</span><span class="mf">1</span><span class="p">])</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="p">[];</span> +<span class="w"> </span><span class="p">}</span> + +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">traceCentralStar</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="nx">coordsR</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">1.5e11</span><span class="p">],</span> +<span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="nx">coordsR</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">1.5e11</span><span class="p">],</span> +<span class="w"> </span><span class="nx">mode</span><span class="o">:</span><span class="w"> </span><span class="s1">'markers'</span><span class="p">,</span> +<span class="w"> </span><span class="nx">type</span><span class="o">:</span><span class="w"> </span><span class="s1">'scatter'</span><span class="p">,</span> +<span class="w"> </span><span class="nx">name</span><span class="o">:</span><span class="w"> </span><span class="s1">'Central star'</span><span class="p">,</span> +<span class="w"> </span><span class="nx">marker</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">color</span><span class="o">:</span><span class="w"> </span><span class="s1">'gold'</span><span class="p">,</span><span class="w"> </span><span class="nx">symbol</span><span class="o">:</span><span class="w"> </span><span class="s1">'star'</span><span class="p">,</span><span class="w"> </span><span class="nx">size</span><span class="o">:</span><span class="w"> </span><span class="mf">10</span><span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="p">};</span> + +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">xCoords</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coordsR</span><span class="p">[</span><span class="mf">0</span><span class="p">].</span><span class="nx">slice</span><span class="p">(</span><span class="mf">1</span><span class="p">).</span><span class="nx">map</span><span class="p">(</span><span class="nx">x</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">x</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">1.5e11</span><span class="p">);</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">yCoords</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coordsR</span><span class="p">[</span><span class="mf">1</span><span class="p">].</span><span class="nx">slice</span><span class="p">(</span><span class="mf">1</span><span class="p">).</span><span class="nx">map</span><span class="p">(</span><span class="nx">y</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">y</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">1.5e11</span><span class="p">);</span> + +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">traceOtherBodies</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="nx">xCoords</span><span class="p">,</span> +<span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="nx">yCoords</span><span class="p">,</span> +<span class="w"> </span><span class="nx">mode</span><span class="o">:</span><span class="w"> </span><span class="s1">'markers'</span><span class="p">,</span> +<span class="w"> </span><span class="nx">type</span><span class="o">:</span><span class="w"> </span><span class="s1">'scatter'</span><span class="p">,</span> +<span class="w"> </span><span class="nx">name</span><span class="o">:</span><span class="w"> </span><span class="s1">''</span><span class="p">,</span> +<span class="w"> </span><span class="nx">marker</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">color</span><span class="o">:</span><span class="w"> </span><span class="s1">'dodgerblue'</span><span class="p">,</span><span class="w"> </span><span class="nx">symbol</span><span class="o">:</span><span class="w"> </span><span class="s1">'circle'</span><span class="p">,</span><span class="w"> </span><span class="nx">size</span><span class="o">:</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="p">};</span> + +<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="p">[</span><span class="nx">traceCentralStar</span><span class="p">,</span><span class="w"> </span><span class="nx">traceOtherBodies</span><span class="p">];</span> +<span class="w"> </span><span class="p">}</span> + + +<span class="w"> </span><span class="kd">function</span><span class="w"> </span><span class="nx">createLayout</span><span class="p">(</span><span class="nx">i</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">title</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">text</span><span class="o">:</span><span class="w"> </span><span class="sb">`N-Body Problem: t = </span><span class="si">${</span><span class="nb">Number</span><span class="p">(</span><span class="nx">t</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nx">yearSec</span><span class="p">).</span><span class="nx">toFixed</span><span class="p">(</span><span class="mf">3</span><span class="p">)</span><span class="si">}</span><span class="sb"> years`</span><span class="p">,</span> +<span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="mf">0.03</span><span class="p">,</span> +<span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="mf">0.97</span><span class="p">,</span> +<span class="w"> </span><span class="nx">xanchor</span><span class="o">:</span><span class="w"> </span><span class="s1">'left'</span><span class="p">,</span> +<span class="w"> </span><span class="nx">yanchor</span><span class="o">:</span><span class="w"> </span><span class="s1">'top'</span><span class="p">,</span> +<span class="w"> </span><span class="nx">font</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">size</span><span class="o">:</span><span class="w"> </span><span class="mf">14</span><span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="nx">xaxis</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">title</span><span class="o">:</span><span class="w"> </span><span class="s1">'x [AU]'</span><span class="p">,</span><span class="w"> </span><span class="nx">range</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="mf">2.1</span><span class="p">,</span><span class="w"> </span><span class="mf">2.1</span><span class="p">]</span><span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="nx">yaxis</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">title</span><span class="o">:</span><span class="w"> </span><span class="s1">'y [AU]'</span><span class="p">,</span><span class="w"> </span><span class="nx">range</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="mf">2.1</span><span class="p">,</span><span class="w"> </span><span class="mf">2.1</span><span class="p">],</span><span class="w"> </span><span class="nx">scaleanchor</span><span class="o">:</span><span class="w"> </span><span class="s1">'x'</span><span class="p">,</span><span class="w"> </span><span class="nx">scaleratio</span><span class="o">:</span><span class="w"> </span><span class="mf">1</span><span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="nx">showlegend</span><span class="o">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span> +<span class="w"> </span><span class="nx">margin</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">l</span><span class="o">:</span><span class="w"> </span><span class="mf">60</span><span class="p">,</span><span class="w"> </span><span class="nx">r</span><span class="o">:</span><span class="w"> </span><span class="mf">40</span><span class="p">,</span><span class="w"> </span><span class="nx">t</span><span class="o">:</span><span class="w"> </span><span class="mf">40</span><span class="p">,</span><span class="w"> </span><span class="nx">b</span><span class="o">:</span><span class="w"> </span><span class="mf">40</span><span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="nx">width</span><span class="o">:</span><span class="w"> </span><span class="mf">800</span><span class="p">,</span> +<span class="w"> </span><span class="nx">height</span><span class="o">:</span><span class="w"> </span><span class="mf">800</span><span class="p">,</span> +<span class="w"> </span><span class="nx">plot_bgcolor</span><span class="o">:</span><span class="w"> </span><span class="s1">'black'</span><span class="p">,</span> +<span class="w"> </span><span class="p">};</span> +<span class="p">}</span> + +<span class="w"> </span><span class="kd">function</span><span class="w"> </span><span class="nx">animateNBodyProblem</span><span class="p">()</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">nFrames</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">tR</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> + +<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kd">let</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">nFrames</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">frameData</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">createFrame</span><span class="p">(</span><span class="nx">coordsRecordR</span><span class="p">[</span><span class="nx">i</span><span class="p">]);</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">layout</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">createLayout</span><span class="p">(</span><span class="nx">i</span><span class="p">);</span> +<span class="w"> </span><span class="c1">//Plotly.newPlot(plotDiv, frameData, layout);</span> +<span class="w"> </span><span class="k">try</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">Plotly</span><span class="p">.</span><span class="nx">animate</span><span class="p">(</span><span class="s2">"plot"</span><span class="p">,</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">data</span><span class="o">:</span><span class="w"> </span><span class="nx">frameData</span><span class="p">,</span><span class="w"> </span><span class="nx">layout</span><span class="o">:</span><span class="w"> </span><span class="nx">layout</span> +<span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">staticPlot</span><span class="o">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span> +<span class="w"> </span><span class="nx">transition</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">duration</span><span class="o">:</span><span class="w"> </span><span class="mf">0</span><span class="p">,</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="nx">frame</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">duration</span><span class="o">:</span><span class="w"> </span><span class="mf">0</span><span class="p">,</span> +<span class="w"> </span><span class="nx">redraw</span><span class="o">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="p">});</span> +<span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">catch</span><span class="w"> </span><span class="p">(</span><span class="nx">err</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">Plotly</span><span class="p">.</span><span class="nx">newPlot</span><span class="p">(</span><span class="s1">'plot'</span><span class="p">,</span><span class="w"> </span><span class="nx">frameData</span><span class="p">,</span><span class="w"> </span><span class="nx">layout</span><span class="p">);</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="p">}</span> +<span class="p">}</span> + +<span class="nx">animateNBodyProblem</span><span class="p">();</span> </code></pre> </div> <h2>Playground</h2> <script src="https://cdn.plot.ly/plotly-latest.min.js"></script> + <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjs/11.8.0/math.js"></script> + <script src="/assets/n-body/script.js"></script> + <div id="main-plot-div"> <noscript> The simulations require JavaScript to be viewed properly :( @@ -5878,10 +5901,12 @@ The simulations require JavaScript to be viewed properly :( <input type="number" min="1" max="10000" value="7e3" id="vRange"> </div> -<button type="button" id="startSim1" onclick="plotEarthSun()">Sun-Earth Orbit</button> + +<p><button type="button" id="startSim1" onclick="plotEarthSun()">Sun-Earth Orbit</button> <button type="button" id="startSim2" onclick="plotClassic3BodyProblem()">Classic 3-Body Problem</button> <button type="button" id="startSim3" onclick="plotRandomNBodySimulation()">Random n-Body Simulation</button> -<button type="button" id="startSim4" onclick="plotRandom3BodySimulation()">Random 3-Body Simulation</button> +<button type="button" id="startSim4" onclick="plotRandom3BodySimulation()">Random 3-Body Simulation</button></p> + <script> function clearAl() { plotOrbit = false; @@ -6186,7 +6211,7 @@ return path(str, boost::filesystem::native); <span class="k">def</span> <span class="nf">execute_command</span><span class="p">(</span><span class="n">command_text</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> - <span class="sd">"""Execute a Siri command."""</span> +<span class="w"> </span><span class="sd">"""Execute a Siri command."""</span> <span class="n">script</span> <span class="o">=</span> <span class="n">applescript</span><span class="o">.</span><span class="n">AppleScript</span><span class="p">(</span><span class="sa">f</span><span class="s2">"""</span> <span class="s2"> tell application "System Events" to tell the front menu bar of process "SystemUIServer"</span> @@ -6223,8 +6248,8 @@ return path(str, boost::filesystem::native); <p>Usage:</p> <div class="codehilite"> -<pre><span></span><code>python3 main.py <span class="s2">"play some taylor swift"</span> -python3 main.py <span class="s2">"turn off the lights and play some music"</span> --openai +<pre><span></span><code>python3<span class="w"> </span>main.py<span class="w"> </span><span class="s2">"play some taylor swift"</span> +python3<span class="w"> </span>main.py<span class="w"> </span><span class="s2">"turn off the lights and play some music"</span><span class="w"> </span>--openai </code></pre> </div> @@ -6261,7 +6286,7 @@ python3 main.py <span class="s2">"turn off the lights and play some music&q <pre><span></span><code><span class="kn">import</span> <span class="nn">applescript</span> <span class="k">def</span> <span class="nf">execute_command</span><span class="p">(</span><span class="n">command_text</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> - <span class="sd">"""Execute a Siri command."""</span> +<span class="w"> </span><span class="sd">"""Execute a Siri command."""</span> <span class="n">script</span> <span class="o">=</span> <span class="n">applescript</span><span class="o">.</span><span class="n">AppleScript</span><span class="p">(</span><span class="sa">f</span><span class="s2">"""</span> <span class="s2"> tell application "System Events" to tell the front menu bar of process "SystemUIServer"</span> @@ -6519,39 +6544,39 @@ python3 main.py <span class="s2">"turn off the lights and play some music&q <p>\</p> <div class="codehilite"> -<pre><span></span><code><span class="nt">+-------------------------+------------------------+</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">path</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">image</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="nt">+-------------------------+------------------------+</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">./train/default/1.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">./train/default/10.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">./train/default/100.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">./train/default/101.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">./train/default/102.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">./train/default/103.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">./train/default/104.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">./train/default/105.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">./train/default/106.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">./train/default/107.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="nt">+-------------------------+------------------------+</span><span class="w"></span> +<pre><span></span><code><span class="nt">+-------------------------+------------------------+</span> +<span class="err">|</span><span class="w"> </span><span class="err">path</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">image</span><span class="w"> </span><span class="err">|</span> +<span class="nt">+-------------------------+------------------------+</span> +<span class="err">|</span><span class="w"> </span><span class="err">./train/default/1.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">./train/default/10.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">./train/default/100.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">./train/default/101.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">./train/default/102.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">./train/default/103.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">./train/default/104.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">./train/default/105.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">./train/default/106.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">./train/default/107.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span> +<span class="nt">+-------------------------+------------------------+</span> <span class="nt">[2028</span><span class="na"> rows x 2 columns]</span> -<span class="na">Note</span><span class="p">:</span><span class="err"> </span><span class="nc">Only</span><span class="err"> </span><span class="nc">the</span><span class="err"> </span><span class="nc">head</span><span class="err"> </span><span class="nc">of</span><span class="err"> </span><span class="nc">the</span><span class="err"> </span><span class="nc">SFrame</span><span class="err"> </span><span class="nc">is</span><span class="err"> </span><span class="nc">printed.</span><span class="w"></span> +<span class="na">Note</span><span class="p">:</span><span class="err"> </span><span class="nc">Only</span><span class="err"> </span><span class="nc">the</span><span class="err"> </span><span class="nc">head</span><span class="err"> </span><span class="nc">of</span><span class="err"> </span><span class="nc">the</span><span class="err"> </span><span class="nc">SFrame</span><span class="err"> </span><span class="nc">is</span><span class="err"> </span><span class="nc">printed.</span> <span class="nt">You</span><span class="na"> can use print_rows(num_rows=m, num_columns=n) to print more rows and columns.</span> <span class="na">+-------------------------+------------------------+---------+</span> -<span class="p">|</span><span class="na"> path </span><span class="p">|</span><span class="na"> image </span><span class="p">|</span><span class="na"> label </span><span class="p">|</span><span class="w"></span> -<span class="nt">+-------------------------+------------------------+---------+</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">./train/default/1.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">default</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">./train/default/10.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">default</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">./train/default/100.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">default</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">./train/default/101.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">default</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">./train/default/102.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">default</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">./train/default/103.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">default</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">./train/default/104.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">default</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">./train/default/105.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">default</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">./train/default/106.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">default</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">./train/default/107.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">default</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="nt">+-------------------------+------------------------+---------+</span><span class="w"></span> +<span class="p">|</span><span class="na"> path </span><span class="p">|</span><span class="na"> image </span><span class="p">|</span><span class="na"> label </span><span class="p">|</span> +<span class="nt">+-------------------------+------------------------+---------+</span> +<span class="err">|</span><span class="w"> </span><span class="err">./train/default/1.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">default</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">./train/default/10.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">default</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">./train/default/100.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">default</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">./train/default/101.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">default</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">./train/default/102.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">default</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">./train/default/103.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">default</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">./train/default/104.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">default</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">./train/default/105.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">default</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">./train/default/106.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">default</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">./train/default/107.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">default</span><span class="w"> </span><span class="err">|</span> +<span class="nt">+-------------------------+------------------------+---------+</span> <span class="nt">[2028</span><span class="na"> rows x 3 columns]</span> -<span class="na">Note</span><span class="p">:</span><span class="err"> </span><span class="nc">Only</span><span class="err"> </span><span class="nc">the</span><span class="err"> </span><span class="nc">head</span><span class="err"> </span><span class="nc">of</span><span class="err"> </span><span class="nc">the</span><span class="err"> </span><span class="nc">SFrame</span><span class="err"> </span><span class="nc">is</span><span class="err"> </span><span class="nc">printed.</span><span class="w"></span> +<span class="na">Note</span><span class="p">:</span><span class="err"> </span><span class="nc">Only</span><span class="err"> </span><span class="nc">the</span><span class="err"> </span><span class="nc">head</span><span class="err"> </span><span class="nc">of</span><span class="err"> </span><span class="nc">the</span><span class="err"> </span><span class="nc">SFrame</span><span class="err"> </span><span class="nc">is</span><span class="err"> </span><span class="nc">printed.</span> <span class="nt">You</span><span class="na"> can use print_rows(num_rows=m, num_columns=n) to print more rows and columns.</span> </code></pre> </div> @@ -6615,28 +6640,28 @@ python3 main.py <span class="s2">"turn off the lights and play some music&q <span class="na">Completed 1536/1633</span> <span class="na">Completed 1600/1633</span> <span class="na">Completed 1633/1633</span> -<span class="na">PROGRESS</span><span class="p">:</span><span class="err"> </span><span class="nc">Creating</span><span class="err"> </span><span class="nc">a</span><span class="err"> </span><span class="nc">validation</span><span class="err"> </span><span class="nc">set</span><span class="err"> </span><span class="nc">from</span><span class="err"> </span><span class="nc">5</span><span class="err"> </span><span class="nc">percent</span><span class="err"> </span><span class="nc">of</span><span class="err"> </span><span class="nc">training</span><span class="err"> </span><span class="nc">data.</span><span class="err"> </span><span class="nc">This</span><span class="err"> </span><span class="nc">may</span><span class="err"> </span><span class="nc">take</span><span class="err"> </span><span class="nc">a</span><span class="err"> </span><span class="nc">while.</span><span class="w"></span> -<span class="w"> </span><span class="err">You</span><span class="w"> </span><span class="err">can</span><span class="w"> </span><span class="err">set</span><span class="w"> </span><span class="err">``validation_set=None``</span><span class="w"> </span><span class="err">to</span><span class="w"> </span><span class="err">disable</span><span class="w"> </span><span class="err">validation</span><span class="w"> </span><span class="err">tracking.</span><span class="w"></span> - -<span class="nt">Logistic</span><span class="na"> regression</span><span class="p">:</span><span class="w"></span> -<span class="nt">--------------------------------------------------------</span><span class="w"></span> -<span class="nt">Number</span><span class="na"> of examples </span><span class="p">:</span><span class="err"> </span><span class="nc">1551</span><span class="w"></span> -<span class="nt">Number</span><span class="na"> of classes </span><span class="p">:</span><span class="err"> </span><span class="nc">3</span><span class="w"></span> -<span class="nt">Number</span><span class="na"> of feature columns </span><span class="p">:</span><span class="err"> </span><span class="nc">1</span><span class="w"></span> -<span class="nt">Number</span><span class="na"> of unpacked features </span><span class="p">:</span><span class="err"> </span><span class="nc">2048</span><span class="w"></span> -<span class="nt">Number</span><span class="na"> of coefficients </span><span class="p">:</span><span class="err"> </span><span class="nc">4098</span><span class="w"></span> +<span class="na">PROGRESS</span><span class="p">:</span><span class="err"> </span><span class="nc">Creating</span><span class="err"> </span><span class="nc">a</span><span class="err"> </span><span class="nc">validation</span><span class="err"> </span><span class="nc">set</span><span class="err"> </span><span class="nc">from</span><span class="err"> </span><span class="nc">5</span><span class="err"> </span><span class="nc">percent</span><span class="err"> </span><span class="nc">of</span><span class="err"> </span><span class="nc">training</span><span class="err"> </span><span class="nc">data.</span><span class="err"> </span><span class="nc">This</span><span class="err"> </span><span class="nc">may</span><span class="err"> </span><span class="nc">take</span><span class="err"> </span><span class="nc">a</span><span class="err"> </span><span class="nc">while.</span> +<span class="w"> </span><span class="err">You</span><span class="w"> </span><span class="err">can</span><span class="w"> </span><span class="err">set</span><span class="w"> </span><span class="err">``validation_set=None``</span><span class="w"> </span><span class="err">to</span><span class="w"> </span><span class="err">disable</span><span class="w"> </span><span class="err">validation</span><span class="w"> </span><span class="err">tracking.</span> + +<span class="nt">Logistic</span><span class="na"> regression</span><span class="p">:</span> +<span class="nt">--------------------------------------------------------</span> +<span class="nt">Number</span><span class="na"> of examples </span><span class="p">:</span><span class="err"> </span><span class="nc">1551</span> +<span class="nt">Number</span><span class="na"> of classes </span><span class="p">:</span><span class="err"> </span><span class="nc">3</span> +<span class="nt">Number</span><span class="na"> of feature columns </span><span class="p">:</span><span class="err"> </span><span class="nc">1</span> +<span class="nt">Number</span><span class="na"> of unpacked features </span><span class="p">:</span><span class="err"> </span><span class="nc">2048</span> +<span class="nt">Number</span><span class="na"> of coefficients </span><span class="p">:</span><span class="err"> </span><span class="nc">4098</span> <span class="nt">Starting</span><span class="na"> L-BFGS</span> <span class="na">--------------------------------------------------------</span> <span class="na">+-----------+----------+-----------+--------------+-------------------+---------------------+</span> -<span class="p">|</span><span class="na"> Iteration </span><span class="p">|</span><span class="na"> Passes </span><span class="p">|</span><span class="na"> Step size </span><span class="p">|</span><span class="na"> Elapsed Time </span><span class="p">|</span><span class="na"> Training Accuracy </span><span class="p">|</span><span class="na"> Validation Accuracy </span><span class="p">|</span><span class="w"></span> -<span class="nt">+-----------+----------+-----------+--------------+-------------------+---------------------+</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">0</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">6</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.018611</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.891830</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.553836</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.560976</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">1</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">10</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.390832</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">1.622383</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.744681</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.792683</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">2</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">11</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.488541</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">1.943987</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.733075</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.804878</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">3</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">14</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">2.442703</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">2.512545</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.727917</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.841463</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">4</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">15</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">2.442703</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">2.826964</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.861380</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.853659</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">9</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">28</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">2.340435</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">5.492035</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.941328</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.975610</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="nt">+-----------+----------+-----------+--------------+-------------------+---------------------+</span><span class="w"></span> +<span class="p">|</span><span class="na"> Iteration </span><span class="p">|</span><span class="na"> Passes </span><span class="p">|</span><span class="na"> Step size </span><span class="p">|</span><span class="na"> Elapsed Time </span><span class="p">|</span><span class="na"> Training Accuracy </span><span class="p">|</span><span class="na"> Validation Accuracy </span><span class="p">|</span> +<span class="nt">+-----------+----------+-----------+--------------+-------------------+---------------------+</span> +<span class="err">|</span><span class="w"> </span><span class="err">0</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">6</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.018611</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.891830</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.553836</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.560976</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">1</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">10</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.390832</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">1.622383</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.744681</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.792683</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">2</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">11</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.488541</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">1.943987</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.733075</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.804878</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">3</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">14</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">2.442703</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">2.512545</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.727917</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.841463</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">4</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">15</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">2.442703</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">2.826964</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.861380</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.853659</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">9</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">28</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">2.340435</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">5.492035</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.941328</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.975610</span><span class="w"> </span><span class="err">|</span> +<span class="nt">+-----------+----------+-----------+--------------+-------------------+---------------------+</span> <span class="nt">Performing</span><span class="na"> feature extraction on resized images...</span> <span class="na">Completed 64/395</span> <span class="na">Completed 128/395</span> @@ -6765,7 +6790,9 @@ brew cask install obs-virtualcam <link rel="stylesheet" href="/assets/posts/obs/dics.css"></p> <script src="/assets/posts/obs/dics.js"></script> -</head> + +<p></head></p> + <script> new Dics({ diff --git a/docs/posts/2019-12-16-TensorFlow-Polynomial-Regression.html b/docs/posts/2019-12-16-TensorFlow-Polynomial-Regression.html index c3876de..ccee075 100644 --- a/docs/posts/2019-12-16-TensorFlow-Polynomial-Regression.html +++ b/docs/posts/2019-12-16-TensorFlow-Polynomial-Regression.html @@ -268,31 +268,31 @@ values using the X values. We then plot it to compare the actual data and predic </div> <div class="codehilite"> -<pre><span></span><code><span class="nt">Epoch</span><span class="na"> 1000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 2000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 3000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 4000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 5000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 6000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 7000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 8000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 9000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 10000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 11000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 12000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 13000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 14000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 15000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 16000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 17000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 18000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 19000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 20000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 21000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 22000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 23000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 24000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 25000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span><span class="w"></span> +<pre><span></span><code><span class="nt">Epoch</span><span class="na"> 1000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 2000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 3000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 4000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 5000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 6000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 7000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 8000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 9000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 10000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 11000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 12000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 13000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 14000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 15000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 16000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 17000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 18000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 19000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 20000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 21000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 22000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 23000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 24000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> +<span class="nt">Epoch</span><span class="na"> 25000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">88999125000.0</span><span class="err"> </span><span class="nc">a,b</span><span class="p">:</span><span class="err"> </span><span class="nc">180396.42</span><span class="err"> </span><span class="nc">-478869.12</span> <span class="nt">88999125000.0</span><span class="na"> 180396.42 -478869.12</span> </code></pre> </div> @@ -333,31 +333,31 @@ values using the X values. We then plot it to compare the actual data and predic </div> <div class="codehilite"> -<pre><span></span><code><span class="nt">Epoch</span><span class="na"> 1000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">52571360000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">1002.4456</span><span class="err"> </span><span class="nc">1097.0197</span><span class="err"> </span><span class="nc">1276.6921</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 2000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">37798890000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">1952.4263</span><span class="err"> </span><span class="nc">2130.2825</span><span class="err"> </span><span class="nc">2469.7756</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 3000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">26751185000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">2839.5825</span><span class="err"> </span><span class="nc">3081.6118</span><span class="err"> </span><span class="nc">3554.351</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 4000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">19020106000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">3644.56</span><span class="err"> </span><span class="nc">3922.9563</span><span class="err"> </span><span class="nc">4486.3135</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 5000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">14060446000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">4345.042</span><span class="err"> </span><span class="nc">4621.4233</span><span class="err"> </span><span class="nc">5212.693</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 6000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">11201084000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">4921.1855</span><span class="err"> </span><span class="nc">5148.1504</span><span class="err"> </span><span class="nc">5689.0713</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 7000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">9732740000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">5364.764</span><span class="err"> </span><span class="nc">5493.0156</span><span class="err"> </span><span class="nc">5906.754</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 8000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">9050918000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">5685.4067</span><span class="err"> </span><span class="nc">5673.182</span><span class="err"> </span><span class="nc">5902.0728</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 9000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8750394000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">5906.9814</span><span class="err"> </span><span class="nc">5724.8906</span><span class="err"> </span><span class="nc">5734.746</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 10000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8613128000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6057.3677</span><span class="err"> </span><span class="nc">5687.3364</span><span class="err"> </span><span class="nc">5461.167</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 11000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8540034600.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6160.547</span><span class="err"> </span><span class="nc">5592.3022</span><span class="err"> </span><span class="nc">5122.8633</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 12000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8490983000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6233.9175</span><span class="err"> </span><span class="nc">5462.025</span><span class="err"> </span><span class="nc">4747.111</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 13000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8450816500.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6289.048</span><span class="err"> </span><span class="nc">5310.7583</span><span class="err"> </span><span class="nc">4350.6997</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 14000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8414082000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6333.199</span><span class="err"> </span><span class="nc">5147.394</span><span class="err"> </span><span class="nc">3943.9294</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 15000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8378841600.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6370.7944</span><span class="err"> </span><span class="nc">4977.1704</span><span class="err"> </span><span class="nc">3532.476</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 16000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8344471000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6404.468</span><span class="err"> </span><span class="nc">4803.542</span><span class="err"> </span><span class="nc">3120.2087</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 17000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8310785500.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6435.365</span><span class="err"> </span><span class="nc">4628.1523</span><span class="err"> </span><span class="nc">2709.1445</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 18000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8277482000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6465.5493</span><span class="err"> </span><span class="nc">4451.833</span><span class="err"> </span><span class="nc">2300.2783</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 19000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8244650000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6494.609</span><span class="err"> </span><span class="nc">4274.826</span><span class="err"> </span><span class="nc">1894.3738</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 20000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8212349000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6522.8247</span><span class="err"> </span><span class="nc">4098.1733</span><span class="err"> </span><span class="nc">1491.9915</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 21000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8180598300.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6550.6567</span><span class="err"> </span><span class="nc">3922.7405</span><span class="err"> </span><span class="nc">1093.3868</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 22000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8149257700.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6578.489</span><span class="err"> </span><span class="nc">3747.8362</span><span class="err"> </span><span class="nc">698.53357</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 23000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8118325000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6606.1973</span><span class="err"> </span><span class="nc">3573.2742</span><span class="err"> </span><span class="nc">307.3541</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 24000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8088001000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6632.96</span><span class="err"> </span><span class="nc">3399.878</span><span class="err"> </span><span class="nc">-79.89219</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 25000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8058094600.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6659.793</span><span class="err"> </span><span class="nc">3227.2517</span><span class="err"> </span><span class="nc">-463.03156</span><span class="w"></span> +<pre><span></span><code><span class="nt">Epoch</span><span class="na"> 1000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">52571360000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">1002.4456</span><span class="err"> </span><span class="nc">1097.0197</span><span class="err"> </span><span class="nc">1276.6921</span> +<span class="nt">Epoch</span><span class="na"> 2000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">37798890000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">1952.4263</span><span class="err"> </span><span class="nc">2130.2825</span><span class="err"> </span><span class="nc">2469.7756</span> +<span class="nt">Epoch</span><span class="na"> 3000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">26751185000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">2839.5825</span><span class="err"> </span><span class="nc">3081.6118</span><span class="err"> </span><span class="nc">3554.351</span> +<span class="nt">Epoch</span><span class="na"> 4000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">19020106000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">3644.56</span><span class="err"> </span><span class="nc">3922.9563</span><span class="err"> </span><span class="nc">4486.3135</span> +<span class="nt">Epoch</span><span class="na"> 5000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">14060446000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">4345.042</span><span class="err"> </span><span class="nc">4621.4233</span><span class="err"> </span><span class="nc">5212.693</span> +<span class="nt">Epoch</span><span class="na"> 6000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">11201084000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">4921.1855</span><span class="err"> </span><span class="nc">5148.1504</span><span class="err"> </span><span class="nc">5689.0713</span> +<span class="nt">Epoch</span><span class="na"> 7000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">9732740000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">5364.764</span><span class="err"> </span><span class="nc">5493.0156</span><span class="err"> </span><span class="nc">5906.754</span> +<span class="nt">Epoch</span><span class="na"> 8000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">9050918000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">5685.4067</span><span class="err"> </span><span class="nc">5673.182</span><span class="err"> </span><span class="nc">5902.0728</span> +<span class="nt">Epoch</span><span class="na"> 9000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8750394000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">5906.9814</span><span class="err"> </span><span class="nc">5724.8906</span><span class="err"> </span><span class="nc">5734.746</span> +<span class="nt">Epoch</span><span class="na"> 10000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8613128000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6057.3677</span><span class="err"> </span><span class="nc">5687.3364</span><span class="err"> </span><span class="nc">5461.167</span> +<span class="nt">Epoch</span><span class="na"> 11000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8540034600.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6160.547</span><span class="err"> </span><span class="nc">5592.3022</span><span class="err"> </span><span class="nc">5122.8633</span> +<span class="nt">Epoch</span><span class="na"> 12000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8490983000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6233.9175</span><span class="err"> </span><span class="nc">5462.025</span><span class="err"> </span><span class="nc">4747.111</span> +<span class="nt">Epoch</span><span class="na"> 13000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8450816500.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6289.048</span><span class="err"> </span><span class="nc">5310.7583</span><span class="err"> </span><span class="nc">4350.6997</span> +<span class="nt">Epoch</span><span class="na"> 14000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8414082000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6333.199</span><span class="err"> </span><span class="nc">5147.394</span><span class="err"> </span><span class="nc">3943.9294</span> +<span class="nt">Epoch</span><span class="na"> 15000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8378841600.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6370.7944</span><span class="err"> </span><span class="nc">4977.1704</span><span class="err"> </span><span class="nc">3532.476</span> +<span class="nt">Epoch</span><span class="na"> 16000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8344471000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6404.468</span><span class="err"> </span><span class="nc">4803.542</span><span class="err"> </span><span class="nc">3120.2087</span> +<span class="nt">Epoch</span><span class="na"> 17000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8310785500.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6435.365</span><span class="err"> </span><span class="nc">4628.1523</span><span class="err"> </span><span class="nc">2709.1445</span> +<span class="nt">Epoch</span><span class="na"> 18000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8277482000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6465.5493</span><span class="err"> </span><span class="nc">4451.833</span><span class="err"> </span><span class="nc">2300.2783</span> +<span class="nt">Epoch</span><span class="na"> 19000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8244650000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6494.609</span><span class="err"> </span><span class="nc">4274.826</span><span class="err"> </span><span class="nc">1894.3738</span> +<span class="nt">Epoch</span><span class="na"> 20000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8212349000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6522.8247</span><span class="err"> </span><span class="nc">4098.1733</span><span class="err"> </span><span class="nc">1491.9915</span> +<span class="nt">Epoch</span><span class="na"> 21000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8180598300.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6550.6567</span><span class="err"> </span><span class="nc">3922.7405</span><span class="err"> </span><span class="nc">1093.3868</span> +<span class="nt">Epoch</span><span class="na"> 22000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8149257700.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6578.489</span><span class="err"> </span><span class="nc">3747.8362</span><span class="err"> </span><span class="nc">698.53357</span> +<span class="nt">Epoch</span><span class="na"> 23000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8118325000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6606.1973</span><span class="err"> </span><span class="nc">3573.2742</span><span class="err"> </span><span class="nc">307.3541</span> +<span class="nt">Epoch</span><span class="na"> 24000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8088001000.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6632.96</span><span class="err"> </span><span class="nc">3399.878</span><span class="err"> </span><span class="nc">-79.89219</span> +<span class="nt">Epoch</span><span class="na"> 25000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">8058094600.0</span><span class="err"> </span><span class="nc">a,b,c</span><span class="p">:</span><span class="err"> </span><span class="nc">6659.793</span><span class="err"> </span><span class="nc">3227.2517</span><span class="err"> </span><span class="nc">-463.03156</span> <span class="nt">8058094600.0</span><span class="na"> 6659.793 3227.2517 -463.03156</span> </code></pre> </div> @@ -399,31 +399,31 @@ values using the X values. We then plot it to compare the actual data and predic </div> <div class="codehilite"> -<pre><span></span><code><span class="nt">Epoch</span><span class="na"> 1000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">4279814000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">670.1527</span><span class="err"> </span><span class="nc">694.4212</span><span class="err"> </span><span class="nc">751.4653</span><span class="err"> </span><span class="nc">903.9527</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 2000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3770950400.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">742.6414</span><span class="err"> </span><span class="nc">666.3489</span><span class="err"> </span><span class="nc">636.94525</span><span class="err"> </span><span class="nc">859.2088</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 3000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3717708300.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">756.2582</span><span class="err"> </span><span class="nc">569.3339</span><span class="err"> </span><span class="nc">448.105</span><span class="err"> </span><span class="nc">748.23956</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 4000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3667464000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">769.4476</span><span class="err"> </span><span class="nc">474.0318</span><span class="err"> </span><span class="nc">265.5761</span><span class="err"> </span><span class="nc">654.75525</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 5000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3620040700.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">782.32324</span><span class="err"> </span><span class="nc">380.54272</span><span class="err"> </span><span class="nc">89.39888</span><span class="err"> </span><span class="nc">578.5136</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 6000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3575265800.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">794.8898</span><span class="err"> </span><span class="nc">288.83356</span><span class="err"> </span><span class="nc">-80.5215</span><span class="err"> </span><span class="nc">519.13654</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 7000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3532972000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">807.1608</span><span class="err"> </span><span class="nc">198.87044</span><span class="err"> </span><span class="nc">-244.31102</span><span class="err"> </span><span class="nc">476.2061</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 8000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3493009200.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">819.13513</span><span class="err"> </span><span class="nc">110.64169</span><span class="err"> </span><span class="nc">-402.0677</span><span class="err"> </span><span class="nc">449.3291</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 9000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3455228400.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">830.80255</span><span class="err"> </span><span class="nc">24.0964</span><span class="err"> </span><span class="nc">-553.92804</span><span class="err"> </span><span class="nc">438.0652</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 10000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3419475500.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">842.21594</span><span class="err"> </span><span class="nc">-60.797424</span><span class="err"> </span><span class="nc">-700.0123</span><span class="err"> </span><span class="nc">441.983</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 11000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3385625300.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">853.3363</span><span class="err"> </span><span class="nc">-144.08699</span><span class="err"> </span><span class="nc">-840.467</span><span class="err"> </span><span class="nc">460.6356</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 12000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3353544700.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">864.19135</span><span class="err"> </span><span class="nc">-225.8125</span><span class="err"> </span><span class="nc">-975.4196</span><span class="err"> </span><span class="nc">493.57703</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 13000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3323125000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">874.778</span><span class="err"> </span><span class="nc">-305.98932</span><span class="err"> </span><span class="nc">-1104.9867</span><span class="err"> </span><span class="nc">540.39465</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 14000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3294257000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">885.1007</span><span class="err"> </span><span class="nc">-384.63474</span><span class="err"> </span><span class="nc">-1229.277</span><span class="err"> </span><span class="nc">600.65607</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 15000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3266820000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">895.18823</span><span class="err"> </span><span class="nc">-461.819</span><span class="err"> </span><span class="nc">-1348.4417</span><span class="err"> </span><span class="nc">673.9051</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 16000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3240736000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">905.0128</span><span class="err"> </span><span class="nc">-537.541</span><span class="err"> </span><span class="nc">-1462.6171</span><span class="err"> </span><span class="nc">759.7118</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 17000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3215895000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">914.60065</span><span class="err"> </span><span class="nc">-611.8676</span><span class="err"> </span><span class="nc">-1571.9058</span><span class="err"> </span><span class="nc">857.6638</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 18000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3192216800.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">923.9603</span><span class="err"> </span><span class="nc">-684.8093</span><span class="err"> </span><span class="nc">-1676.4642</span><span class="err"> </span><span class="nc">967.30475</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 19000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3169632300.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">933.08594</span><span class="err"> </span><span class="nc">-756.3582</span><span class="err"> </span><span class="nc">-1776.4275</span><span class="err"> </span><span class="nc">1088.2198</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 20000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3148046300.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">941.9928</span><span class="err"> </span><span class="nc">-826.6257</span><span class="err"> </span><span class="nc">-1871.9355</span><span class="err"> </span><span class="nc">1219.9702</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 21000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3127394800.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">950.67896</span><span class="err"> </span><span class="nc">-895.6205</span><span class="err"> </span><span class="nc">-1963.0989</span><span class="err"> </span><span class="nc">1362.1665</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 22000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3107608600.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">959.1487</span><span class="err"> </span><span class="nc">-963.38116</span><span class="err"> </span><span class="nc">-2050.0586</span><span class="err"> </span><span class="nc">1514.4026</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 23000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3088618200.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">967.4355</span><span class="err"> </span><span class="nc">-1029.9625</span><span class="err"> </span><span class="nc">-2132.961</span><span class="err"> </span><span class="nc">1676.2717</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 24000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3070361300.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">975.52875</span><span class="err"> </span><span class="nc">-1095.4292</span><span class="err"> </span><span class="nc">-2211.854</span><span class="err"> </span><span class="nc">1847.4485</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 25000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3052791300.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">983.4346</span><span class="err"> </span><span class="nc">-1159.7922</span><span class="err"> </span><span class="nc">-2286.9412</span><span class="err"> </span><span class="nc">2027.4857</span><span class="w"></span> +<pre><span></span><code><span class="nt">Epoch</span><span class="na"> 1000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">4279814000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">670.1527</span><span class="err"> </span><span class="nc">694.4212</span><span class="err"> </span><span class="nc">751.4653</span><span class="err"> </span><span class="nc">903.9527</span> +<span class="nt">Epoch</span><span class="na"> 2000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3770950400.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">742.6414</span><span class="err"> </span><span class="nc">666.3489</span><span class="err"> </span><span class="nc">636.94525</span><span class="err"> </span><span class="nc">859.2088</span> +<span class="nt">Epoch</span><span class="na"> 3000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3717708300.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">756.2582</span><span class="err"> </span><span class="nc">569.3339</span><span class="err"> </span><span class="nc">448.105</span><span class="err"> </span><span class="nc">748.23956</span> +<span class="nt">Epoch</span><span class="na"> 4000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3667464000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">769.4476</span><span class="err"> </span><span class="nc">474.0318</span><span class="err"> </span><span class="nc">265.5761</span><span class="err"> </span><span class="nc">654.75525</span> +<span class="nt">Epoch</span><span class="na"> 5000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3620040700.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">782.32324</span><span class="err"> </span><span class="nc">380.54272</span><span class="err"> </span><span class="nc">89.39888</span><span class="err"> </span><span class="nc">578.5136</span> +<span class="nt">Epoch</span><span class="na"> 6000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3575265800.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">794.8898</span><span class="err"> </span><span class="nc">288.83356</span><span class="err"> </span><span class="nc">-80.5215</span><span class="err"> </span><span class="nc">519.13654</span> +<span class="nt">Epoch</span><span class="na"> 7000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3532972000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">807.1608</span><span class="err"> </span><span class="nc">198.87044</span><span class="err"> </span><span class="nc">-244.31102</span><span class="err"> </span><span class="nc">476.2061</span> +<span class="nt">Epoch</span><span class="na"> 8000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3493009200.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">819.13513</span><span class="err"> </span><span class="nc">110.64169</span><span class="err"> </span><span class="nc">-402.0677</span><span class="err"> </span><span class="nc">449.3291</span> +<span class="nt">Epoch</span><span class="na"> 9000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3455228400.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">830.80255</span><span class="err"> </span><span class="nc">24.0964</span><span class="err"> </span><span class="nc">-553.92804</span><span class="err"> </span><span class="nc">438.0652</span> +<span class="nt">Epoch</span><span class="na"> 10000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3419475500.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">842.21594</span><span class="err"> </span><span class="nc">-60.797424</span><span class="err"> </span><span class="nc">-700.0123</span><span class="err"> </span><span class="nc">441.983</span> +<span class="nt">Epoch</span><span class="na"> 11000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3385625300.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">853.3363</span><span class="err"> </span><span class="nc">-144.08699</span><span class="err"> </span><span class="nc">-840.467</span><span class="err"> </span><span class="nc">460.6356</span> +<span class="nt">Epoch</span><span class="na"> 12000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3353544700.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">864.19135</span><span class="err"> </span><span class="nc">-225.8125</span><span class="err"> </span><span class="nc">-975.4196</span><span class="err"> </span><span class="nc">493.57703</span> +<span class="nt">Epoch</span><span class="na"> 13000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3323125000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">874.778</span><span class="err"> </span><span class="nc">-305.98932</span><span class="err"> </span><span class="nc">-1104.9867</span><span class="err"> </span><span class="nc">540.39465</span> +<span class="nt">Epoch</span><span class="na"> 14000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3294257000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">885.1007</span><span class="err"> </span><span class="nc">-384.63474</span><span class="err"> </span><span class="nc">-1229.277</span><span class="err"> </span><span class="nc">600.65607</span> +<span class="nt">Epoch</span><span class="na"> 15000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3266820000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">895.18823</span><span class="err"> </span><span class="nc">-461.819</span><span class="err"> </span><span class="nc">-1348.4417</span><span class="err"> </span><span class="nc">673.9051</span> +<span class="nt">Epoch</span><span class="na"> 16000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3240736000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">905.0128</span><span class="err"> </span><span class="nc">-537.541</span><span class="err"> </span><span class="nc">-1462.6171</span><span class="err"> </span><span class="nc">759.7118</span> +<span class="nt">Epoch</span><span class="na"> 17000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3215895000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">914.60065</span><span class="err"> </span><span class="nc">-611.8676</span><span class="err"> </span><span class="nc">-1571.9058</span><span class="err"> </span><span class="nc">857.6638</span> +<span class="nt">Epoch</span><span class="na"> 18000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3192216800.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">923.9603</span><span class="err"> </span><span class="nc">-684.8093</span><span class="err"> </span><span class="nc">-1676.4642</span><span class="err"> </span><span class="nc">967.30475</span> +<span class="nt">Epoch</span><span class="na"> 19000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3169632300.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">933.08594</span><span class="err"> </span><span class="nc">-756.3582</span><span class="err"> </span><span class="nc">-1776.4275</span><span class="err"> </span><span class="nc">1088.2198</span> +<span class="nt">Epoch</span><span class="na"> 20000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3148046300.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">941.9928</span><span class="err"> </span><span class="nc">-826.6257</span><span class="err"> </span><span class="nc">-1871.9355</span><span class="err"> </span><span class="nc">1219.9702</span> +<span class="nt">Epoch</span><span class="na"> 21000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3127394800.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">950.67896</span><span class="err"> </span><span class="nc">-895.6205</span><span class="err"> </span><span class="nc">-1963.0989</span><span class="err"> </span><span class="nc">1362.1665</span> +<span class="nt">Epoch</span><span class="na"> 22000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3107608600.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">959.1487</span><span class="err"> </span><span class="nc">-963.38116</span><span class="err"> </span><span class="nc">-2050.0586</span><span class="err"> </span><span class="nc">1514.4026</span> +<span class="nt">Epoch</span><span class="na"> 23000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3088618200.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">967.4355</span><span class="err"> </span><span class="nc">-1029.9625</span><span class="err"> </span><span class="nc">-2132.961</span><span class="err"> </span><span class="nc">1676.2717</span> +<span class="nt">Epoch</span><span class="na"> 24000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3070361300.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">975.52875</span><span class="err"> </span><span class="nc">-1095.4292</span><span class="err"> </span><span class="nc">-2211.854</span><span class="err"> </span><span class="nc">1847.4485</span> +<span class="nt">Epoch</span><span class="na"> 25000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">3052791300.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">983.4346</span><span class="err"> </span><span class="nc">-1159.7922</span><span class="err"> </span><span class="nc">-2286.9412</span><span class="err"> </span><span class="nc">2027.4857</span> <span class="nt">3052791300.0</span><span class="na"> 983.4346 -1159.7922 -2286.9412 2027.4857</span> </code></pre> </div> @@ -466,31 +466,31 @@ values using the X values. We then plot it to compare the actual data and predic </div> <div class="codehilite"> -<pre><span></span><code><span class="nt">Epoch</span><span class="na"> 1000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1902632600.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">84.48304</span><span class="err"> </span><span class="nc">52.210594</span><span class="err"> </span><span class="nc">54.791424</span><span class="err"> </span><span class="nc">142.51952</span><span class="err"> </span><span class="nc">512.0343</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 2000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1854316200.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">88.998955</span><span class="err"> </span><span class="nc">13.073557</span><span class="err"> </span><span class="nc">14.276088</span><span class="err"> </span><span class="nc">223.55667</span><span class="err"> </span><span class="nc">1056.4655</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 3000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1812812400.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">92.9462</span><span class="err"> </span><span class="nc">-22.331177</span><span class="err"> </span><span class="nc">-15.262934</span><span class="err"> </span><span class="nc">327.41858</span><span class="err"> </span><span class="nc">1634.9054</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 4000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1775716000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">96.42522</span><span class="err"> </span><span class="nc">-54.64535</span><span class="err"> </span><span class="nc">-35.829437</span><span class="err"> </span><span class="nc">449.5028</span><span class="err"> </span><span class="nc">2239.1392</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 5000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1741494100.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">99.524734</span><span class="err"> </span><span class="nc">-84.43976</span><span class="err"> </span><span class="nc">-49.181057</span><span class="err"> </span><span class="nc">585.85876</span><span class="err"> </span><span class="nc">2862.4915</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 6000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1709199600.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">102.31984</span><span class="err"> </span><span class="nc">-112.19895</span><span class="err"> </span><span class="nc">-56.808075</span><span class="err"> </span><span class="nc">733.1876</span><span class="err"> </span><span class="nc">3499.6199</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 7000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1678261800.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">104.87324</span><span class="err"> </span><span class="nc">-138.32709</span><span class="err"> </span><span class="nc">-59.9442</span><span class="err"> </span><span class="nc">888.79626</span><span class="err"> </span><span class="nc">4146.2944</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 8000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1648340600.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">107.23536</span><span class="err"> </span><span class="nc">-163.15173</span><span class="err"> </span><span class="nc">-59.58964</span><span class="err"> </span><span class="nc">1050.524</span><span class="err"> </span><span class="nc">4798.979</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 9000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1619243400.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">109.44742</span><span class="err"> </span><span class="nc">-186.9409</span><span class="err"> </span><span class="nc">-56.53944</span><span class="err"> </span><span class="nc">1216.6432</span><span class="err"> </span><span class="nc">5454.9463</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 10000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1590821900.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">111.54233</span><span class="err"> </span><span class="nc">-209.91287</span><span class="err"> </span><span class="nc">-51.423084</span><span class="err"> </span><span class="nc">1385.8513</span><span class="err"> </span><span class="nc">6113.5137</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 11000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1563042200.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">113.54405</span><span class="err"> </span><span class="nc">-232.21953</span><span class="err"> </span><span class="nc">-44.73371</span><span class="err"> </span><span class="nc">1557.1084</span><span class="err"> </span><span class="nc">6771.7046</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 12000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1535855600.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">115.471565</span><span class="err"> </span><span class="nc">-253.9838</span><span class="err"> </span><span class="nc">-36.851135</span><span class="err"> </span><span class="nc">1729.535</span><span class="err"> </span><span class="nc">7429.069</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 13000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1509255300.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">117.33939</span><span class="err"> </span><span class="nc">-275.29697</span><span class="err"> </span><span class="nc">-28.0714</span><span class="err"> </span><span class="nc">1902.5308</span><span class="err"> </span><span class="nc">8083.9634</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 14000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1483227000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">119.1605</span><span class="err"> </span><span class="nc">-296.2472</span><span class="err"> </span><span class="nc">-18.618649</span><span class="err"> </span><span class="nc">2075.6094</span><span class="err"> </span><span class="nc">8735.381</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 15000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1457726700.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">120.94584</span><span class="err"> </span><span class="nc">-316.915</span><span class="err"> </span><span class="nc">-8.650095</span><span class="err"> </span><span class="nc">2248.3247</span><span class="err"> </span><span class="nc">9384.197</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 16000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1432777300.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">122.69806</span><span class="err"> </span><span class="nc">-337.30704</span><span class="err"> </span><span class="nc">1.7027153</span><span class="err"> </span><span class="nc">2420.5771</span><span class="err"> </span><span class="nc">10028.871</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 17000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1408365000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">124.42179</span><span class="err"> </span><span class="nc">-357.45245</span><span class="err"> </span><span class="nc">12.33499</span><span class="err"> </span><span class="nc">2592.2983</span><span class="err"> </span><span class="nc">10669.157</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 18000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1384480000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">126.12332</span><span class="err"> </span><span class="nc">-377.39734</span><span class="err"> </span><span class="nc">23.168756</span><span class="err"> </span><span class="nc">2763.0933</span><span class="err"> </span><span class="nc">11305.027</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 19000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1361116800.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">127.80568</span><span class="err"> </span><span class="nc">-397.16415</span><span class="err"> </span><span class="nc">34.160156</span><span class="err"> </span><span class="nc">2933.0452</span><span class="err"> </span><span class="nc">11935.669</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 20000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1338288100.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">129.4674</span><span class="err"> </span><span class="nc">-416.72803</span><span class="err"> </span><span class="nc">45.259155</span><span class="err"> </span><span class="nc">3101.7727</span><span class="err"> </span><span class="nc">12561.179</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 21000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1315959700.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">131.11403</span><span class="err"> </span><span class="nc">-436.14285</span><span class="err"> </span><span class="nc">56.4436</span><span class="err"> </span><span class="nc">3269.3142</span><span class="err"> </span><span class="nc">13182.058</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 22000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1294164700.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">132.74377</span><span class="err"> </span><span class="nc">-455.3779</span><span class="err"> </span><span class="nc">67.6757</span><span class="err"> </span><span class="nc">3435.3833</span><span class="err"> </span><span class="nc">13796.807</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 23000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1272863600.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">134.35779</span><span class="err"> </span><span class="nc">-474.45316</span><span class="err"> </span><span class="nc">78.96117</span><span class="err"> </span><span class="nc">3600.264</span><span class="err"> </span><span class="nc">14406.58</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 24000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1252052600.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">135.9583</span><span class="err"> </span><span class="nc">-493.38254</span><span class="err"> </span><span class="nc">90.268616</span><span class="err"> </span><span class="nc">3764.0078</span><span class="err"> </span><span class="nc">15010.481</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 25000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1231713700.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">137.54753</span><span class="err"> </span><span class="nc">-512.1876</span><span class="err"> </span><span class="nc">101.59372</span><span class="err"> </span><span class="nc">3926.4897</span><span class="err"> </span><span class="nc">15609.368</span><span class="w"></span> +<pre><span></span><code><span class="nt">Epoch</span><span class="na"> 1000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1902632600.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">84.48304</span><span class="err"> </span><span class="nc">52.210594</span><span class="err"> </span><span class="nc">54.791424</span><span class="err"> </span><span class="nc">142.51952</span><span class="err"> </span><span class="nc">512.0343</span> +<span class="nt">Epoch</span><span class="na"> 2000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1854316200.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">88.998955</span><span class="err"> </span><span class="nc">13.073557</span><span class="err"> </span><span class="nc">14.276088</span><span class="err"> </span><span class="nc">223.55667</span><span class="err"> </span><span class="nc">1056.4655</span> +<span class="nt">Epoch</span><span class="na"> 3000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1812812400.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">92.9462</span><span class="err"> </span><span class="nc">-22.331177</span><span class="err"> </span><span class="nc">-15.262934</span><span class="err"> </span><span class="nc">327.41858</span><span class="err"> </span><span class="nc">1634.9054</span> +<span class="nt">Epoch</span><span class="na"> 4000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1775716000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">96.42522</span><span class="err"> </span><span class="nc">-54.64535</span><span class="err"> </span><span class="nc">-35.829437</span><span class="err"> </span><span class="nc">449.5028</span><span class="err"> </span><span class="nc">2239.1392</span> +<span class="nt">Epoch</span><span class="na"> 5000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1741494100.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">99.524734</span><span class="err"> </span><span class="nc">-84.43976</span><span class="err"> </span><span class="nc">-49.181057</span><span class="err"> </span><span class="nc">585.85876</span><span class="err"> </span><span class="nc">2862.4915</span> +<span class="nt">Epoch</span><span class="na"> 6000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1709199600.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">102.31984</span><span class="err"> </span><span class="nc">-112.19895</span><span class="err"> </span><span class="nc">-56.808075</span><span class="err"> </span><span class="nc">733.1876</span><span class="err"> </span><span class="nc">3499.6199</span> +<span class="nt">Epoch</span><span class="na"> 7000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1678261800.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">104.87324</span><span class="err"> </span><span class="nc">-138.32709</span><span class="err"> </span><span class="nc">-59.9442</span><span class="err"> </span><span class="nc">888.79626</span><span class="err"> </span><span class="nc">4146.2944</span> +<span class="nt">Epoch</span><span class="na"> 8000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1648340600.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">107.23536</span><span class="err"> </span><span class="nc">-163.15173</span><span class="err"> </span><span class="nc">-59.58964</span><span class="err"> </span><span class="nc">1050.524</span><span class="err"> </span><span class="nc">4798.979</span> +<span class="nt">Epoch</span><span class="na"> 9000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1619243400.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">109.44742</span><span class="err"> </span><span class="nc">-186.9409</span><span class="err"> </span><span class="nc">-56.53944</span><span class="err"> </span><span class="nc">1216.6432</span><span class="err"> </span><span class="nc">5454.9463</span> +<span class="nt">Epoch</span><span class="na"> 10000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1590821900.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">111.54233</span><span class="err"> </span><span class="nc">-209.91287</span><span class="err"> </span><span class="nc">-51.423084</span><span class="err"> </span><span class="nc">1385.8513</span><span class="err"> </span><span class="nc">6113.5137</span> +<span class="nt">Epoch</span><span class="na"> 11000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1563042200.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">113.54405</span><span class="err"> </span><span class="nc">-232.21953</span><span class="err"> </span><span class="nc">-44.73371</span><span class="err"> </span><span class="nc">1557.1084</span><span class="err"> </span><span class="nc">6771.7046</span> +<span class="nt">Epoch</span><span class="na"> 12000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1535855600.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">115.471565</span><span class="err"> </span><span class="nc">-253.9838</span><span class="err"> </span><span class="nc">-36.851135</span><span class="err"> </span><span class="nc">1729.535</span><span class="err"> </span><span class="nc">7429.069</span> +<span class="nt">Epoch</span><span class="na"> 13000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1509255300.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">117.33939</span><span class="err"> </span><span class="nc">-275.29697</span><span class="err"> </span><span class="nc">-28.0714</span><span class="err"> </span><span class="nc">1902.5308</span><span class="err"> </span><span class="nc">8083.9634</span> +<span class="nt">Epoch</span><span class="na"> 14000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1483227000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">119.1605</span><span class="err"> </span><span class="nc">-296.2472</span><span class="err"> </span><span class="nc">-18.618649</span><span class="err"> </span><span class="nc">2075.6094</span><span class="err"> </span><span class="nc">8735.381</span> +<span class="nt">Epoch</span><span class="na"> 15000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1457726700.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">120.94584</span><span class="err"> </span><span class="nc">-316.915</span><span class="err"> </span><span class="nc">-8.650095</span><span class="err"> </span><span class="nc">2248.3247</span><span class="err"> </span><span class="nc">9384.197</span> +<span class="nt">Epoch</span><span class="na"> 16000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1432777300.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">122.69806</span><span class="err"> </span><span class="nc">-337.30704</span><span class="err"> </span><span class="nc">1.7027153</span><span class="err"> </span><span class="nc">2420.5771</span><span class="err"> </span><span class="nc">10028.871</span> +<span class="nt">Epoch</span><span class="na"> 17000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1408365000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">124.42179</span><span class="err"> </span><span class="nc">-357.45245</span><span class="err"> </span><span class="nc">12.33499</span><span class="err"> </span><span class="nc">2592.2983</span><span class="err"> </span><span class="nc">10669.157</span> +<span class="nt">Epoch</span><span class="na"> 18000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1384480000.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">126.12332</span><span class="err"> </span><span class="nc">-377.39734</span><span class="err"> </span><span class="nc">23.168756</span><span class="err"> </span><span class="nc">2763.0933</span><span class="err"> </span><span class="nc">11305.027</span> +<span class="nt">Epoch</span><span class="na"> 19000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1361116800.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">127.80568</span><span class="err"> </span><span class="nc">-397.16415</span><span class="err"> </span><span class="nc">34.160156</span><span class="err"> </span><span class="nc">2933.0452</span><span class="err"> </span><span class="nc">11935.669</span> +<span class="nt">Epoch</span><span class="na"> 20000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1338288100.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">129.4674</span><span class="err"> </span><span class="nc">-416.72803</span><span class="err"> </span><span class="nc">45.259155</span><span class="err"> </span><span class="nc">3101.7727</span><span class="err"> </span><span class="nc">12561.179</span> +<span class="nt">Epoch</span><span class="na"> 21000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1315959700.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">131.11403</span><span class="err"> </span><span class="nc">-436.14285</span><span class="err"> </span><span class="nc">56.4436</span><span class="err"> </span><span class="nc">3269.3142</span><span class="err"> </span><span class="nc">13182.058</span> +<span class="nt">Epoch</span><span class="na"> 22000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1294164700.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">132.74377</span><span class="err"> </span><span class="nc">-455.3779</span><span class="err"> </span><span class="nc">67.6757</span><span class="err"> </span><span class="nc">3435.3833</span><span class="err"> </span><span class="nc">13796.807</span> +<span class="nt">Epoch</span><span class="na"> 23000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1272863600.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">134.35779</span><span class="err"> </span><span class="nc">-474.45316</span><span class="err"> </span><span class="nc">78.96117</span><span class="err"> </span><span class="nc">3600.264</span><span class="err"> </span><span class="nc">14406.58</span> +<span class="nt">Epoch</span><span class="na"> 24000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1252052600.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">135.9583</span><span class="err"> </span><span class="nc">-493.38254</span><span class="err"> </span><span class="nc">90.268616</span><span class="err"> </span><span class="nc">3764.0078</span><span class="err"> </span><span class="nc">15010.481</span> +<span class="nt">Epoch</span><span class="na"> 25000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1231713700.0</span><span class="err"> </span><span class="nc">a,b,c,d</span><span class="p">:</span><span class="err"> </span><span class="nc">137.54753</span><span class="err"> </span><span class="nc">-512.1876</span><span class="err"> </span><span class="nc">101.59372</span><span class="err"> </span><span class="nc">3926.4897</span><span class="err"> </span><span class="nc">15609.368</span> <span class="nt">1231713700.0</span><span class="na"> 137.54753 -512.1876 101.59372 3926.4897 15609.368</span> </code></pre> </div> @@ -532,31 +532,31 @@ values using the X values. We then plot it to compare the actual data and predic </div> <div class="codehilite"> -<pre><span></span><code><span class="nt">Epoch</span><span class="na"> 1000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1409200100.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">7.949472</span><span class="err"> </span><span class="nc">7.46219</span><span class="err"> </span><span class="nc">55.626034</span><span class="err"> </span><span class="nc">184.29028</span><span class="err"> </span><span class="nc">484.00223</span><span class="err"> </span><span class="nc">1024.0083</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 2000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1306882400.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">8.732181</span><span class="err"> </span><span class="nc">-4.0085897</span><span class="err"> </span><span class="nc">73.25298</span><span class="err"> </span><span class="nc">315.90103</span><span class="err"> </span><span class="nc">904.08887</span><span class="err"> </span><span class="nc">2004.9749</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 3000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1212606000.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">9.732249</span><span class="err"> </span><span class="nc">-16.90125</span><span class="err"> </span><span class="nc">86.28379</span><span class="err"> </span><span class="nc">437.06552</span><span class="err"> </span><span class="nc">1305.055</span><span class="err"> </span><span class="nc">2966.2188</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 4000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1123640400.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">10.74851</span><span class="err"> </span><span class="nc">-29.82692</span><span class="err"> </span><span class="nc">98.59997</span><span class="err"> </span><span class="nc">555.331</span><span class="err"> </span><span class="nc">1698.4631</span><span class="err"> </span><span class="nc">3917.9155</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 5000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1039694300.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">11.75426</span><span class="err"> </span><span class="nc">-42.598194</span><span class="err"> </span><span class="nc">110.698326</span><span class="err"> </span><span class="nc">671.64355</span><span class="err"> </span><span class="nc">2085.5513</span><span class="err"> </span><span class="nc">4860.8535</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 6000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">960663550.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">12.745439</span><span class="err"> </span><span class="nc">-55.18337</span><span class="err"> </span><span class="nc">122.644936</span><span class="err"> </span><span class="nc">786.00214</span><span class="err"> </span><span class="nc">2466.1638</span><span class="err"> </span><span class="nc">5794.3735</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 7000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">886438340.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">13.721028</span><span class="err"> </span><span class="nc">-67.57168</span><span class="err"> </span><span class="nc">134.43822</span><span class="err"> </span><span class="nc">898.3691</span><span class="err"> </span><span class="nc">2839.9958</span><span class="err"> </span><span class="nc">6717.659</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 8000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">816913100.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">14.679965</span><span class="err"> </span><span class="nc">-79.75113</span><span class="err"> </span><span class="nc">146.07385</span><span class="err"> </span><span class="nc">1008.66895</span><span class="err"> </span><span class="nc">3206.6692</span><span class="err"> </span><span class="nc">7629.812</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 9000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">751971500.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">15.62181</span><span class="err"> </span><span class="nc">-91.71608</span><span class="err"> </span><span class="nc">157.55713</span><span class="err"> </span><span class="nc">1116.7715</span><span class="err"> </span><span class="nc">3565.8323</span><span class="err"> </span><span class="nc">8529.976</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 10000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">691508740.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">16.545347</span><span class="err"> </span><span class="nc">-103.4531</span><span class="err"> </span><span class="nc">168.88321</span><span class="err"> </span><span class="nc">1222.6348</span><span class="err"> </span><span class="nc">3916.9785</span><span class="err"> </span><span class="nc">9416.236</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 11000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">635382000.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">17.450052</span><span class="err"> </span><span class="nc">-114.954254</span><span class="err"> </span><span class="nc">180.03932</span><span class="err"> </span><span class="nc">1326.1565</span><span class="err"> </span><span class="nc">4259.842</span><span class="err"> </span><span class="nc">10287.99</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 12000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">583477250.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">18.334944</span><span class="err"> </span><span class="nc">-126.20821</span><span class="err"> </span><span class="nc">191.02948</span><span class="err"> </span><span class="nc">1427.2095</span><span class="err"> </span><span class="nc">4593.8</span><span class="err"> </span><span class="nc">11143.449</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 13000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">535640400.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">19.198917</span><span class="err"> </span><span class="nc">-137.20206</span><span class="err"> </span><span class="nc">201.84718</span><span class="err"> </span><span class="nc">1525.6926</span><span class="err"> </span><span class="nc">4918.5327</span><span class="err"> </span><span class="nc">11981.633</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 14000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">491722240.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">20.041153</span><span class="err"> </span><span class="nc">-147.92719</span><span class="err"> </span><span class="nc">212.49709</span><span class="err"> </span><span class="nc">1621.5496</span><span class="err"> </span><span class="nc">5233.627</span><span class="err"> </span><span class="nc">12800.468</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 15000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">451559520.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">20.860966</span><span class="err"> </span><span class="nc">-158.37456</span><span class="err"> </span><span class="nc">222.97133</span><span class="err"> </span><span class="nc">1714.7141</span><span class="err"> </span><span class="nc">5538.676</span><span class="err"> </span><span class="nc">13598.337</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 16000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">414988960.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">21.657421</span><span class="err"> </span><span class="nc">-168.53406</span><span class="err"> </span><span class="nc">233.27422</span><span class="err"> </span><span class="nc">1805.0874</span><span class="err"> </span><span class="nc">5833.1978</span><span class="err"> </span><span class="nc">14373.658</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 17000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">381837920.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">22.429693</span><span class="err"> </span><span class="nc">-178.39536</span><span class="err"> </span><span class="nc">243.39914</span><span class="err"> </span><span class="nc">1892.5883</span><span class="err"> </span><span class="nc">6116.847</span><span class="err"> </span><span class="nc">15124.394</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 18000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">351931300.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">23.176882</span><span class="err"> </span><span class="nc">-187.94789</span><span class="err"> </span><span class="nc">253.3445</span><span class="err"> </span><span class="nc">1977.137</span><span class="err"> </span><span class="nc">6389.117</span><span class="err"> </span><span class="nc">15848.417</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 19000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">325074400.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">23.898485</span><span class="err"> </span><span class="nc">-197.18741</span><span class="err"> </span><span class="nc">263.12512</span><span class="err"> </span><span class="nc">2058.6716</span><span class="err"> </span><span class="nc">6649.8037</span><span class="err"> </span><span class="nc">16543.95</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 20000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">301073570.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">24.593851</span><span class="err"> </span><span class="nc">-206.10497</span><span class="err"> </span><span class="nc">272.72385</span><span class="err"> </span><span class="nc">2137.1797</span><span class="err"> </span><span class="nc">6898.544</span><span class="err"> </span><span class="nc">17209.367</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 21000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">279727000.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">25.262104</span><span class="err"> </span><span class="nc">-214.69217</span><span class="err"> </span><span class="nc">282.14642</span><span class="err"> </span><span class="nc">2212.6372</span><span class="err"> </span><span class="nc">7135.217</span><span class="err"> </span><span class="nc">17842.854</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 22000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">260845550.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">25.903376</span><span class="err"> </span><span class="nc">-222.94969</span><span class="err"> </span><span class="nc">291.4003</span><span class="err"> </span><span class="nc">2284.9844</span><span class="err"> </span><span class="nc">7359.4644</span><span class="err"> </span><span class="nc">18442.408</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 23000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">244218030.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">26.517094</span><span class="err"> </span><span class="nc">-230.8697</span><span class="err"> </span><span class="nc">300.45532</span><span class="err"> </span><span class="nc">2354.3003</span><span class="err"> </span><span class="nc">7571.261</span><span class="err"> </span><span class="nc">19007.49</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 24000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">229660080.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">27.102589</span><span class="err"> </span><span class="nc">-238.44817</span><span class="err"> </span><span class="nc">309.35342</span><span class="err"> </span><span class="nc">2420.4185</span><span class="err"> </span><span class="nc">7770.5728</span><span class="err"> </span><span class="nc">19536.19</span><span class="w"></span> -<span class="nt">Epoch</span><span class="na"> 25000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">216972400.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">27.660324</span><span class="err"> </span><span class="nc">-245.69016</span><span class="err"> </span><span class="nc">318.10062</span><span class="err"> </span><span class="nc">2483.3608</span><span class="err"> </span><span class="nc">7957.354</span><span class="err"> </span><span class="nc">20027.707</span><span class="w"></span> +<pre><span></span><code><span class="nt">Epoch</span><span class="na"> 1000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1409200100.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">7.949472</span><span class="err"> </span><span class="nc">7.46219</span><span class="err"> </span><span class="nc">55.626034</span><span class="err"> </span><span class="nc">184.29028</span><span class="err"> </span><span class="nc">484.00223</span><span class="err"> </span><span class="nc">1024.0083</span> +<span class="nt">Epoch</span><span class="na"> 2000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1306882400.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">8.732181</span><span class="err"> </span><span class="nc">-4.0085897</span><span class="err"> </span><span class="nc">73.25298</span><span class="err"> </span><span class="nc">315.90103</span><span class="err"> </span><span class="nc">904.08887</span><span class="err"> </span><span class="nc">2004.9749</span> +<span class="nt">Epoch</span><span class="na"> 3000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1212606000.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">9.732249</span><span class="err"> </span><span class="nc">-16.90125</span><span class="err"> </span><span class="nc">86.28379</span><span class="err"> </span><span class="nc">437.06552</span><span class="err"> </span><span class="nc">1305.055</span><span class="err"> </span><span class="nc">2966.2188</span> +<span class="nt">Epoch</span><span class="na"> 4000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1123640400.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">10.74851</span><span class="err"> </span><span class="nc">-29.82692</span><span class="err"> </span><span class="nc">98.59997</span><span class="err"> </span><span class="nc">555.331</span><span class="err"> </span><span class="nc">1698.4631</span><span class="err"> </span><span class="nc">3917.9155</span> +<span class="nt">Epoch</span><span class="na"> 5000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">1039694300.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">11.75426</span><span class="err"> </span><span class="nc">-42.598194</span><span class="err"> </span><span class="nc">110.698326</span><span class="err"> </span><span class="nc">671.64355</span><span class="err"> </span><span class="nc">2085.5513</span><span class="err"> </span><span class="nc">4860.8535</span> +<span class="nt">Epoch</span><span class="na"> 6000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">960663550.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">12.745439</span><span class="err"> </span><span class="nc">-55.18337</span><span class="err"> </span><span class="nc">122.644936</span><span class="err"> </span><span class="nc">786.00214</span><span class="err"> </span><span class="nc">2466.1638</span><span class="err"> </span><span class="nc">5794.3735</span> +<span class="nt">Epoch</span><span class="na"> 7000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">886438340.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">13.721028</span><span class="err"> </span><span class="nc">-67.57168</span><span class="err"> </span><span class="nc">134.43822</span><span class="err"> </span><span class="nc">898.3691</span><span class="err"> </span><span class="nc">2839.9958</span><span class="err"> </span><span class="nc">6717.659</span> +<span class="nt">Epoch</span><span class="na"> 8000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">816913100.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">14.679965</span><span class="err"> </span><span class="nc">-79.75113</span><span class="err"> </span><span class="nc">146.07385</span><span class="err"> </span><span class="nc">1008.66895</span><span class="err"> </span><span class="nc">3206.6692</span><span class="err"> </span><span class="nc">7629.812</span> +<span class="nt">Epoch</span><span class="na"> 9000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">751971500.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">15.62181</span><span class="err"> </span><span class="nc">-91.71608</span><span class="err"> </span><span class="nc">157.55713</span><span class="err"> </span><span class="nc">1116.7715</span><span class="err"> </span><span class="nc">3565.8323</span><span class="err"> </span><span class="nc">8529.976</span> +<span class="nt">Epoch</span><span class="na"> 10000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">691508740.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">16.545347</span><span class="err"> </span><span class="nc">-103.4531</span><span class="err"> </span><span class="nc">168.88321</span><span class="err"> </span><span class="nc">1222.6348</span><span class="err"> </span><span class="nc">3916.9785</span><span class="err"> </span><span class="nc">9416.236</span> +<span class="nt">Epoch</span><span class="na"> 11000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">635382000.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">17.450052</span><span class="err"> </span><span class="nc">-114.954254</span><span class="err"> </span><span class="nc">180.03932</span><span class="err"> </span><span class="nc">1326.1565</span><span class="err"> </span><span class="nc">4259.842</span><span class="err"> </span><span class="nc">10287.99</span> +<span class="nt">Epoch</span><span class="na"> 12000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">583477250.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">18.334944</span><span class="err"> </span><span class="nc">-126.20821</span><span class="err"> </span><span class="nc">191.02948</span><span class="err"> </span><span class="nc">1427.2095</span><span class="err"> </span><span class="nc">4593.8</span><span class="err"> </span><span class="nc">11143.449</span> +<span class="nt">Epoch</span><span class="na"> 13000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">535640400.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">19.198917</span><span class="err"> </span><span class="nc">-137.20206</span><span class="err"> </span><span class="nc">201.84718</span><span class="err"> </span><span class="nc">1525.6926</span><span class="err"> </span><span class="nc">4918.5327</span><span class="err"> </span><span class="nc">11981.633</span> +<span class="nt">Epoch</span><span class="na"> 14000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">491722240.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">20.041153</span><span class="err"> </span><span class="nc">-147.92719</span><span class="err"> </span><span class="nc">212.49709</span><span class="err"> </span><span class="nc">1621.5496</span><span class="err"> </span><span class="nc">5233.627</span><span class="err"> </span><span class="nc">12800.468</span> +<span class="nt">Epoch</span><span class="na"> 15000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">451559520.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">20.860966</span><span class="err"> </span><span class="nc">-158.37456</span><span class="err"> </span><span class="nc">222.97133</span><span class="err"> </span><span class="nc">1714.7141</span><span class="err"> </span><span class="nc">5538.676</span><span class="err"> </span><span class="nc">13598.337</span> +<span class="nt">Epoch</span><span class="na"> 16000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">414988960.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">21.657421</span><span class="err"> </span><span class="nc">-168.53406</span><span class="err"> </span><span class="nc">233.27422</span><span class="err"> </span><span class="nc">1805.0874</span><span class="err"> </span><span class="nc">5833.1978</span><span class="err"> </span><span class="nc">14373.658</span> +<span class="nt">Epoch</span><span class="na"> 17000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">381837920.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">22.429693</span><span class="err"> </span><span class="nc">-178.39536</span><span class="err"> </span><span class="nc">243.39914</span><span class="err"> </span><span class="nc">1892.5883</span><span class="err"> </span><span class="nc">6116.847</span><span class="err"> </span><span class="nc">15124.394</span> +<span class="nt">Epoch</span><span class="na"> 18000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">351931300.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">23.176882</span><span class="err"> </span><span class="nc">-187.94789</span><span class="err"> </span><span class="nc">253.3445</span><span class="err"> </span><span class="nc">1977.137</span><span class="err"> </span><span class="nc">6389.117</span><span class="err"> </span><span class="nc">15848.417</span> +<span class="nt">Epoch</span><span class="na"> 19000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">325074400.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">23.898485</span><span class="err"> </span><span class="nc">-197.18741</span><span class="err"> </span><span class="nc">263.12512</span><span class="err"> </span><span class="nc">2058.6716</span><span class="err"> </span><span class="nc">6649.8037</span><span class="err"> </span><span class="nc">16543.95</span> +<span class="nt">Epoch</span><span class="na"> 20000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">301073570.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">24.593851</span><span class="err"> </span><span class="nc">-206.10497</span><span class="err"> </span><span class="nc">272.72385</span><span class="err"> </span><span class="nc">2137.1797</span><span class="err"> </span><span class="nc">6898.544</span><span class="err"> </span><span class="nc">17209.367</span> +<span class="nt">Epoch</span><span class="na"> 21000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">279727000.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">25.262104</span><span class="err"> </span><span class="nc">-214.69217</span><span class="err"> </span><span class="nc">282.14642</span><span class="err"> </span><span class="nc">2212.6372</span><span class="err"> </span><span class="nc">7135.217</span><span class="err"> </span><span class="nc">17842.854</span> +<span class="nt">Epoch</span><span class="na"> 22000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">260845550.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">25.903376</span><span class="err"> </span><span class="nc">-222.94969</span><span class="err"> </span><span class="nc">291.4003</span><span class="err"> </span><span class="nc">2284.9844</span><span class="err"> </span><span class="nc">7359.4644</span><span class="err"> </span><span class="nc">18442.408</span> +<span class="nt">Epoch</span><span class="na"> 23000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">244218030.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">26.517094</span><span class="err"> </span><span class="nc">-230.8697</span><span class="err"> </span><span class="nc">300.45532</span><span class="err"> </span><span class="nc">2354.3003</span><span class="err"> </span><span class="nc">7571.261</span><span class="err"> </span><span class="nc">19007.49</span> +<span class="nt">Epoch</span><span class="na"> 24000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">229660080.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">27.102589</span><span class="err"> </span><span class="nc">-238.44817</span><span class="err"> </span><span class="nc">309.35342</span><span class="err"> </span><span class="nc">2420.4185</span><span class="err"> </span><span class="nc">7770.5728</span><span class="err"> </span><span class="nc">19536.19</span> +<span class="nt">Epoch</span><span class="na"> 25000 </span><span class="p">:</span><span class="err"> </span><span class="nc">Training</span><span class="err"> </span><span class="nc">Cost</span><span class="p">:</span><span class="err"> </span><span class="nc">216972400.0</span><span class="err"> </span><span class="nc">a,b,c,d,e,f</span><span class="p">:</span><span class="err"> </span><span class="nc">27.660324</span><span class="err"> </span><span class="nc">-245.69016</span><span class="err"> </span><span class="nc">318.10062</span><span class="err"> </span><span class="nc">2483.3608</span><span class="err"> </span><span class="nc">7957.354</span><span class="err"> </span><span class="nc">20027.707</span> <span class="nt">216972400.0</span><span class="na"> 27.660324 -245.69016 318.10062 2483.3608 7957.354 20027.707</span> </code></pre> </div> diff --git a/docs/posts/2019-12-22-Fake-News-Detector.html b/docs/posts/2019-12-22-Fake-News-Detector.html index 676a34e..9f76794 100644 --- a/docs/posts/2019-12-22-Fake-News-Detector.html +++ b/docs/posts/2019-12-22-Fake-News-Detector.html @@ -85,7 +85,7 @@ a CUDA compatible MXNet package.</p> <h3>Downloading the Dataset</h3> <div class="codehilite"> -<pre><span></span><code><span class="nt">!wget</span><span class="na"> -q "https</span><span class="p">:</span><span class="nc">//github.com/joolsa/fake_real_news_dataset/raw/master/fake_or_real_news.csv.zip"</span><span class="w"></span> +<pre><span></span><code><span class="nt">!wget</span><span class="na"> -q "https</span><span class="p">:</span><span class="nc">//github.com/joolsa/fake_real_news_dataset/raw/master/fake_or_real_news.csv.zip"</span> <span class="nt">!unzip</span><span class="na"> fake_or_real_news.csv.zip</span> </code></pre> </div> diff --git a/docs/posts/2020-01-16-Image-Classifier-Using-Turicreate.html b/docs/posts/2020-01-16-Image-Classifier-Using-Turicreate.html index c1fea70..dfa8f23 100644 --- a/docs/posts/2020-01-16-Image-Classifier-Using-Turicreate.html +++ b/docs/posts/2020-01-16-Image-Classifier-Using-Turicreate.html @@ -192,39 +192,39 @@ <p>\</p> <div class="codehilite"> -<pre><span></span><code><span class="nt">+-------------------------+------------------------+</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">path</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">image</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="nt">+-------------------------+------------------------+</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">./train/default/1.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">./train/default/10.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">./train/default/100.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">./train/default/101.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">./train/default/102.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">./train/default/103.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">./train/default/104.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">./train/default/105.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">./train/default/106.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">./train/default/107.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="nt">+-------------------------+------------------------+</span><span class="w"></span> +<pre><span></span><code><span class="nt">+-------------------------+------------------------+</span> +<span class="err">|</span><span class="w"> </span><span class="err">path</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">image</span><span class="w"> </span><span class="err">|</span> +<span class="nt">+-------------------------+------------------------+</span> +<span class="err">|</span><span class="w"> </span><span class="err">./train/default/1.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">./train/default/10.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">./train/default/100.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">./train/default/101.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">./train/default/102.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">./train/default/103.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">./train/default/104.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">./train/default/105.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">./train/default/106.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">./train/default/107.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span> +<span class="nt">+-------------------------+------------------------+</span> <span class="nt">[2028</span><span class="na"> rows x 2 columns]</span> -<span class="na">Note</span><span class="p">:</span><span class="err"> </span><span class="nc">Only</span><span class="err"> </span><span class="nc">the</span><span class="err"> </span><span class="nc">head</span><span class="err"> </span><span class="nc">of</span><span class="err"> </span><span class="nc">the</span><span class="err"> </span><span class="nc">SFrame</span><span class="err"> </span><span class="nc">is</span><span class="err"> </span><span class="nc">printed.</span><span class="w"></span> +<span class="na">Note</span><span class="p">:</span><span class="err"> </span><span class="nc">Only</span><span class="err"> </span><span class="nc">the</span><span class="err"> </span><span class="nc">head</span><span class="err"> </span><span class="nc">of</span><span class="err"> </span><span class="nc">the</span><span class="err"> </span><span class="nc">SFrame</span><span class="err"> </span><span class="nc">is</span><span class="err"> </span><span class="nc">printed.</span> <span class="nt">You</span><span class="na"> can use print_rows(num_rows=m, num_columns=n) to print more rows and columns.</span> <span class="na">+-------------------------+------------------------+---------+</span> -<span class="p">|</span><span class="na"> path </span><span class="p">|</span><span class="na"> image </span><span class="p">|</span><span class="na"> label </span><span class="p">|</span><span class="w"></span> -<span class="nt">+-------------------------+------------------------+---------+</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">./train/default/1.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">default</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">./train/default/10.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">default</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">./train/default/100.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">default</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">./train/default/101.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">default</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">./train/default/102.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">default</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">./train/default/103.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">default</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">./train/default/104.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">default</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">./train/default/105.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">default</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">./train/default/106.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">default</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">./train/default/107.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">default</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="nt">+-------------------------+------------------------+---------+</span><span class="w"></span> +<span class="p">|</span><span class="na"> path </span><span class="p">|</span><span class="na"> image </span><span class="p">|</span><span class="na"> label </span><span class="p">|</span> +<span class="nt">+-------------------------+------------------------+---------+</span> +<span class="err">|</span><span class="w"> </span><span class="err">./train/default/1.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">default</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">./train/default/10.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">default</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">./train/default/100.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">default</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">./train/default/101.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">default</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">./train/default/102.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">default</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">./train/default/103.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">default</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">./train/default/104.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">default</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">./train/default/105.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">default</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">./train/default/106.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">default</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">./train/default/107.jpg</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">Height:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">Width:</span><span class="w"> </span><span class="err">224</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">default</span><span class="w"> </span><span class="err">|</span> +<span class="nt">+-------------------------+------------------------+---------+</span> <span class="nt">[2028</span><span class="na"> rows x 3 columns]</span> -<span class="na">Note</span><span class="p">:</span><span class="err"> </span><span class="nc">Only</span><span class="err"> </span><span class="nc">the</span><span class="err"> </span><span class="nc">head</span><span class="err"> </span><span class="nc">of</span><span class="err"> </span><span class="nc">the</span><span class="err"> </span><span class="nc">SFrame</span><span class="err"> </span><span class="nc">is</span><span class="err"> </span><span class="nc">printed.</span><span class="w"></span> +<span class="na">Note</span><span class="p">:</span><span class="err"> </span><span class="nc">Only</span><span class="err"> </span><span class="nc">the</span><span class="err"> </span><span class="nc">head</span><span class="err"> </span><span class="nc">of</span><span class="err"> </span><span class="nc">the</span><span class="err"> </span><span class="nc">SFrame</span><span class="err"> </span><span class="nc">is</span><span class="err"> </span><span class="nc">printed.</span> <span class="nt">You</span><span class="na"> can use print_rows(num_rows=m, num_columns=n) to print more rows and columns.</span> </code></pre> </div> @@ -288,28 +288,28 @@ <span class="na">Completed 1536/1633</span> <span class="na">Completed 1600/1633</span> <span class="na">Completed 1633/1633</span> -<span class="na">PROGRESS</span><span class="p">:</span><span class="err"> </span><span class="nc">Creating</span><span class="err"> </span><span class="nc">a</span><span class="err"> </span><span class="nc">validation</span><span class="err"> </span><span class="nc">set</span><span class="err"> </span><span class="nc">from</span><span class="err"> </span><span class="nc">5</span><span class="err"> </span><span class="nc">percent</span><span class="err"> </span><span class="nc">of</span><span class="err"> </span><span class="nc">training</span><span class="err"> </span><span class="nc">data.</span><span class="err"> </span><span class="nc">This</span><span class="err"> </span><span class="nc">may</span><span class="err"> </span><span class="nc">take</span><span class="err"> </span><span class="nc">a</span><span class="err"> </span><span class="nc">while.</span><span class="w"></span> -<span class="w"> </span><span class="err">You</span><span class="w"> </span><span class="err">can</span><span class="w"> </span><span class="err">set</span><span class="w"> </span><span class="err">``validation_set=None``</span><span class="w"> </span><span class="err">to</span><span class="w"> </span><span class="err">disable</span><span class="w"> </span><span class="err">validation</span><span class="w"> </span><span class="err">tracking.</span><span class="w"></span> - -<span class="nt">Logistic</span><span class="na"> regression</span><span class="p">:</span><span class="w"></span> -<span class="nt">--------------------------------------------------------</span><span class="w"></span> -<span class="nt">Number</span><span class="na"> of examples </span><span class="p">:</span><span class="err"> </span><span class="nc">1551</span><span class="w"></span> -<span class="nt">Number</span><span class="na"> of classes </span><span class="p">:</span><span class="err"> </span><span class="nc">3</span><span class="w"></span> -<span class="nt">Number</span><span class="na"> of feature columns </span><span class="p">:</span><span class="err"> </span><span class="nc">1</span><span class="w"></span> -<span class="nt">Number</span><span class="na"> of unpacked features </span><span class="p">:</span><span class="err"> </span><span class="nc">2048</span><span class="w"></span> -<span class="nt">Number</span><span class="na"> of coefficients </span><span class="p">:</span><span class="err"> </span><span class="nc">4098</span><span class="w"></span> +<span class="na">PROGRESS</span><span class="p">:</span><span class="err"> </span><span class="nc">Creating</span><span class="err"> </span><span class="nc">a</span><span class="err"> </span><span class="nc">validation</span><span class="err"> </span><span class="nc">set</span><span class="err"> </span><span class="nc">from</span><span class="err"> </span><span class="nc">5</span><span class="err"> </span><span class="nc">percent</span><span class="err"> </span><span class="nc">of</span><span class="err"> </span><span class="nc">training</span><span class="err"> </span><span class="nc">data.</span><span class="err"> </span><span class="nc">This</span><span class="err"> </span><span class="nc">may</span><span class="err"> </span><span class="nc">take</span><span class="err"> </span><span class="nc">a</span><span class="err"> </span><span class="nc">while.</span> +<span class="w"> </span><span class="err">You</span><span class="w"> </span><span class="err">can</span><span class="w"> </span><span class="err">set</span><span class="w"> </span><span class="err">``validation_set=None``</span><span class="w"> </span><span class="err">to</span><span class="w"> </span><span class="err">disable</span><span class="w"> </span><span class="err">validation</span><span class="w"> </span><span class="err">tracking.</span> + +<span class="nt">Logistic</span><span class="na"> regression</span><span class="p">:</span> +<span class="nt">--------------------------------------------------------</span> +<span class="nt">Number</span><span class="na"> of examples </span><span class="p">:</span><span class="err"> </span><span class="nc">1551</span> +<span class="nt">Number</span><span class="na"> of classes </span><span class="p">:</span><span class="err"> </span><span class="nc">3</span> +<span class="nt">Number</span><span class="na"> of feature columns </span><span class="p">:</span><span class="err"> </span><span class="nc">1</span> +<span class="nt">Number</span><span class="na"> of unpacked features </span><span class="p">:</span><span class="err"> </span><span class="nc">2048</span> +<span class="nt">Number</span><span class="na"> of coefficients </span><span class="p">:</span><span class="err"> </span><span class="nc">4098</span> <span class="nt">Starting</span><span class="na"> L-BFGS</span> <span class="na">--------------------------------------------------------</span> <span class="na">+-----------+----------+-----------+--------------+-------------------+---------------------+</span> -<span class="p">|</span><span class="na"> Iteration </span><span class="p">|</span><span class="na"> Passes </span><span class="p">|</span><span class="na"> Step size </span><span class="p">|</span><span class="na"> Elapsed Time </span><span class="p">|</span><span class="na"> Training Accuracy </span><span class="p">|</span><span class="na"> Validation Accuracy </span><span class="p">|</span><span class="w"></span> -<span class="nt">+-----------+----------+-----------+--------------+-------------------+---------------------+</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">0</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">6</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.018611</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.891830</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.553836</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.560976</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">1</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">10</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.390832</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">1.622383</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.744681</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.792683</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">2</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">11</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.488541</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">1.943987</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.733075</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.804878</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">3</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">14</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">2.442703</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">2.512545</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.727917</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.841463</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">4</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">15</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">2.442703</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">2.826964</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.861380</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.853659</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="err">|</span><span class="w"> </span><span class="err">9</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">28</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">2.340435</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">5.492035</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.941328</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.975610</span><span class="w"> </span><span class="err">|</span><span class="w"></span> -<span class="nt">+-----------+----------+-----------+--------------+-------------------+---------------------+</span><span class="w"></span> +<span class="p">|</span><span class="na"> Iteration </span><span class="p">|</span><span class="na"> Passes </span><span class="p">|</span><span class="na"> Step size </span><span class="p">|</span><span class="na"> Elapsed Time </span><span class="p">|</span><span class="na"> Training Accuracy </span><span class="p">|</span><span class="na"> Validation Accuracy </span><span class="p">|</span> +<span class="nt">+-----------+----------+-----------+--------------+-------------------+---------------------+</span> +<span class="err">|</span><span class="w"> </span><span class="err">0</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">6</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.018611</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.891830</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.553836</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.560976</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">1</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">10</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.390832</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">1.622383</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.744681</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.792683</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">2</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">11</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.488541</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">1.943987</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.733075</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.804878</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">3</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">14</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">2.442703</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">2.512545</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.727917</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.841463</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">4</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">15</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">2.442703</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">2.826964</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.861380</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.853659</span><span class="w"> </span><span class="err">|</span> +<span class="err">|</span><span class="w"> </span><span class="err">9</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">28</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">2.340435</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">5.492035</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.941328</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="err">0.975610</span><span class="w"> </span><span class="err">|</span> +<span class="nt">+-----------+----------+-----------+--------------+-------------------+---------------------+</span> <span class="nt">Performing</span><span class="na"> feature extraction on resized images...</span> <span class="na">Completed 64/395</span> <span class="na">Completed 128/395</span> diff --git a/docs/posts/2020-08-01-Natural-Feature-Tracking-ARJS.html b/docs/posts/2020-08-01-Natural-Feature-Tracking-ARJS.html index 038dc59..4508a2a 100644 --- a/docs/posts/2020-08-01-Natural-Feature-Tracking-ARJS.html +++ b/docs/posts/2020-08-01-Natural-Feature-Tracking-ARJS.html @@ -201,25 +201,25 @@ me.fset me.fset3 me.iset <pre><span></span><code><span class="p"><</span><span class="nt">script</span> <span class="na">src</span><span class="o">=</span><span class="s">"https://cdn.jsdelivr.net/gh/aframevr/aframe@1c2407b26c61958baa93967b5412487cd94b290b/dist/aframe-master.min.js"</span><span class="p">></</span><span class="nt">script</span><span class="p">></span> <span class="p"><</span><span class="nt">script</span> <span class="na">src</span><span class="o">=</span><span class="s">"https://raw.githack.com/AR-js-org/AR.js/master/aframe/build/aframe-ar-nft.js"</span><span class="p">></</span><span class="nt">script</span><span class="p">></span> -<span class="p"><</span><span class="nt">style</span><span class="p">></span><span class="w"></span> -<span class="w"> </span><span class="p">.</span><span class="nc">arjs-loader</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="k">height</span><span class="p">:</span><span class="w"> </span><span class="mi">100</span><span class="kt">%</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="k">width</span><span class="p">:</span><span class="w"> </span><span class="mi">100</span><span class="kt">%</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="k">position</span><span class="p">:</span><span class="w"> </span><span class="kc">absolute</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="k">top</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="k">left</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="k">background-color</span><span class="p">:</span><span class="w"> </span><span class="nb">rgba</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="mf">0.8</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="k">z-index</span><span class="p">:</span><span class="w"> </span><span class="mi">9999</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="k">display</span><span class="p">:</span><span class="w"> </span><span class="kc">flex</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="k">justify-content</span><span class="p">:</span><span class="w"> </span><span class="kc">center</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="k">align-items</span><span class="p">:</span><span class="w"> </span><span class="kc">center</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> - -<span class="w"> </span><span class="p">.</span><span class="nc">arjs-loader</span><span class="w"> </span><span class="nt">div</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="k">text-align</span><span class="p">:</span><span class="w"> </span><span class="kc">center</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="k">font-size</span><span class="p">:</span><span class="w"> </span><span class="mf">1.25</span><span class="kt">em</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="k">color</span><span class="p">:</span><span class="w"> </span><span class="kc">white</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> +<span class="p"><</span><span class="nt">style</span><span class="p">></span> +<span class="w"> </span><span class="p">.</span><span class="nc">arjs-loader</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="k">height</span><span class="p">:</span><span class="w"> </span><span class="mi">100</span><span class="kt">%</span><span class="p">;</span> +<span class="w"> </span><span class="k">width</span><span class="p">:</span><span class="w"> </span><span class="mi">100</span><span class="kt">%</span><span class="p">;</span> +<span class="w"> </span><span class="k">position</span><span class="p">:</span><span class="w"> </span><span class="kc">absolute</span><span class="p">;</span> +<span class="w"> </span><span class="k">top</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span> +<span class="w"> </span><span class="k">left</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span> +<span class="w"> </span><span class="k">background-color</span><span class="p">:</span><span class="w"> </span><span class="nb">rgba</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="mf">0.8</span><span class="p">);</span> +<span class="w"> </span><span class="k">z-index</span><span class="p">:</span><span class="w"> </span><span class="mi">9999</span><span class="p">;</span> +<span class="w"> </span><span class="k">display</span><span class="p">:</span><span class="w"> </span><span class="kc">flex</span><span class="p">;</span> +<span class="w"> </span><span class="k">justify-content</span><span class="p">:</span><span class="w"> </span><span class="kc">center</span><span class="p">;</span> +<span class="w"> </span><span class="k">align-items</span><span class="p">:</span><span class="w"> </span><span class="kc">center</span><span class="p">;</span> +<span class="w"> </span><span class="p">}</span> + +<span class="w"> </span><span class="p">.</span><span class="nc">arjs-loader</span><span class="w"> </span><span class="nt">div</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="k">text-align</span><span class="p">:</span><span class="w"> </span><span class="kc">center</span><span class="p">;</span> +<span class="w"> </span><span class="k">font-size</span><span class="p">:</span><span class="w"> </span><span class="mf">1.25</span><span class="kt">em</span><span class="p">;</span> +<span class="w"> </span><span class="k">color</span><span class="p">:</span><span class="w"> </span><span class="kc">white</span><span class="p">;</span> +<span class="w"> </span><span class="p">}</span> <span class="p"></</span><span class="nt">style</span><span class="p">></span> <span class="p"><</span><span class="nt">body</span> <span class="na">style</span><span class="o">=</span><span class="s">"margin : 0px; overflow: hidden;"</span><span class="p">></span> diff --git a/docs/posts/2020-10-11-macOS-Virtual-Cam-OBS.html b/docs/posts/2020-10-11-macOS-Virtual-Cam-OBS.html index 2823d2a..d4b5038 100644 --- a/docs/posts/2020-10-11-macOS-Virtual-Cam-OBS.html +++ b/docs/posts/2020-10-11-macOS-Virtual-Cam-OBS.html @@ -154,7 +154,9 @@ brew cask install obs-virtualcam <link rel="stylesheet" href="/assets/posts/obs/dics.css"></p> <script src="/assets/posts/obs/dics.js"></script> -</head> + +<p></head></p> + <script> new Dics({ diff --git a/docs/posts/2020-11-17-Lets-Encrypt-DuckDns.html b/docs/posts/2020-11-17-Lets-Encrypt-DuckDns.html index bc1f6c4..0060954 100644 --- a/docs/posts/2020-11-17-Lets-Encrypt-DuckDns.html +++ b/docs/posts/2020-11-17-Lets-Encrypt-DuckDns.html @@ -61,14 +61,14 @@ <h2>Dependencies</h2> <div class="codehilite"> -<pre><span></span><code>sudo apt update <span class="o">&&</span> sudo apt install certbot -y +<pre><span></span><code>sudo<span class="w"> </span>apt<span class="w"> </span>update<span class="w"> </span><span class="o">&&</span><span class="w"> </span>sudo<span class="w"> </span>apt<span class="w"> </span>install<span class="w"> </span>certbot<span class="w"> </span>-y </code></pre> </div> <h2>Get the Certificate</h2> <div class="codehilite"> -<pre><span></span><code>sudo certbot certonly --manual --preferred-challenges dns-01 --email senpai@email.com -d mydomain.duckdns.org +<pre><span></span><code>sudo<span class="w"> </span>certbot<span class="w"> </span>certonly<span class="w"> </span>--manual<span class="w"> </span>--preferred-challenges<span class="w"> </span>dns-01<span class="w"> </span>--email<span class="w"> </span>senpai@email.com<span class="w"> </span>-d<span class="w"> </span>mydomain.duckdns.org </code></pre> </div> @@ -84,25 +84,25 @@ <p>You can check if the TXT records have been updated by using the <code>dig</code> command:</p> <div class="codehilite"> -<pre><span></span><code>dig navanspi.duckdns.org TXT -<span class="p">;</span> <<>> DiG <span class="m">9</span>.16.1-Ubuntu <<>> navanspi.duckdns.org TXT -<span class="p">;;</span> global options: +cmd -<span class="p">;;</span> Got answer: -<span class="p">;;</span> ->>HEADER<span class="s"><<- opco</span>de: QUERY, status: NOERROR, id: <span class="m">27592</span> -<span class="p">;;</span> flags: qr rd ra<span class="p">;</span> QUERY: <span class="m">1</span>, ANSWER: <span class="m">1</span>, AUTHORITY: <span class="m">0</span>, ADDITIONAL: <span class="m">1</span> - -<span class="p">;;</span> OPT PSEUDOSECTION: -<span class="p">;</span> EDNS: version: <span class="m">0</span>, flags:<span class="p">;</span> udp: <span class="m">65494</span> -<span class="p">;;</span> QUESTION SECTION: -<span class="p">;</span>navanspi.duckdns.org. IN TXT - -<span class="p">;;</span> ANSWER SECTION: -navanspi.duckdns.org. <span class="m">60</span> IN TXT <span class="s2">"4OKbijIJmc82Yv2NiGVm1RmaBHSCZ_230qNtj9YA-qk"</span> - -<span class="p">;;</span> Query time: <span class="m">275</span> msec -<span class="p">;;</span> SERVER: <span class="m">127</span>.0.0.53#53<span class="o">(</span><span class="m">127</span>.0.0.53<span class="o">)</span> -<span class="p">;;</span> WHEN: Tue Nov <span class="m">17</span> <span class="m">15</span>:23:15 IST <span class="m">2020</span> -<span class="p">;;</span> MSG SIZE rcvd: <span class="m">105</span> +<pre><span></span><code>dig<span class="w"> </span>navanspi.duckdns.org<span class="w"> </span>TXT +<span class="p">;</span><span class="w"> </span><<>><span class="w"> </span>DiG<span class="w"> </span><span class="m">9</span>.16.1-Ubuntu<span class="w"> </span><<>><span class="w"> </span>navanspi.duckdns.org<span class="w"> </span>TXT +<span class="p">;;</span><span class="w"> </span>global<span class="w"> </span>options:<span class="w"> </span>+cmd +<span class="p">;;</span><span class="w"> </span>Got<span class="w"> </span>answer: +<span class="p">;;</span><span class="w"> </span>->>HEADER<span class="s"><<- opco</span>de:<span class="w"> </span>QUERY,<span class="w"> </span>status:<span class="w"> </span>NOERROR,<span class="w"> </span>id:<span class="w"> </span><span class="m">27592</span> +<span class="p">;;</span><span class="w"> </span>flags:<span class="w"> </span>qr<span class="w"> </span>rd<span class="w"> </span>ra<span class="p">;</span><span class="w"> </span>QUERY:<span class="w"> </span><span class="m">1</span>,<span class="w"> </span>ANSWER:<span class="w"> </span><span class="m">1</span>,<span class="w"> </span>AUTHORITY:<span class="w"> </span><span class="m">0</span>,<span class="w"> </span>ADDITIONAL:<span class="w"> </span><span class="m">1</span> + +<span class="p">;;</span><span class="w"> </span>OPT<span class="w"> </span>PSEUDOSECTION: +<span class="p">;</span><span class="w"> </span>EDNS:<span class="w"> </span>version:<span class="w"> </span><span class="m">0</span>,<span class="w"> </span>flags:<span class="p">;</span><span class="w"> </span>udp:<span class="w"> </span><span class="m">65494</span> +<span class="p">;;</span><span class="w"> </span>QUESTION<span class="w"> </span>SECTION: +<span class="p">;</span>navanspi.duckdns.org.<span class="w"> </span>IN<span class="w"> </span>TXT + +<span class="p">;;</span><span class="w"> </span>ANSWER<span class="w"> </span>SECTION: +navanspi.duckdns.org.<span class="w"> </span><span class="m">60</span><span class="w"> </span>IN<span class="w"> </span>TXT<span class="w"> </span><span class="s2">"4OKbijIJmc82Yv2NiGVm1RmaBHSCZ_230qNtj9YA-qk"</span> + +<span class="p">;;</span><span class="w"> </span>Query<span class="w"> </span>time:<span class="w"> </span><span class="m">275</span><span class="w"> </span>msec +<span class="p">;;</span><span class="w"> </span>SERVER:<span class="w"> </span><span class="m">127</span>.0.0.53#53<span class="o">(</span><span class="m">127</span>.0.0.53<span class="o">)</span> +<span class="p">;;</span><span class="w"> </span>WHEN:<span class="w"> </span>Tue<span class="w"> </span>Nov<span class="w"> </span><span class="m">17</span><span class="w"> </span><span class="m">15</span>:23:15<span class="w"> </span>IST<span class="w"> </span><span class="m">2020</span> +<span class="p">;;</span><span class="w"> </span>MSG<span class="w"> </span>SIZE<span class="w"> </span>rcvd:<span class="w"> </span><span class="m">105</span> </code></pre> </div> @@ -119,14 +119,14 @@ navanspi.duckdns.org. <span class="m">60</span> IN TXT <span class=" <p>Example Gunicorn command for running a web-app:</p> <div class="codehilite"> -<pre><span></span><code>gunicorn api:app -k uvicorn.workers.UvicornWorker -b <span class="m">0</span>.0.0.0:7589 +<pre><span></span><code>gunicorn<span class="w"> </span>api:app<span class="w"> </span>-k<span class="w"> </span>uvicorn.workers.UvicornWorker<span class="w"> </span>-b<span class="w"> </span><span class="m">0</span>.0.0.0:7589 </code></pre> </div> <p>To use the certificate with it, simply copy the <code>cert.pem</code> and <code>privkey.pem</code> to your working directory ( change the appropriate permissions ) and include them in the command</p> <div class="codehilite"> -<pre><span></span><code>gunicorn api:app -k uvicorn.workers.UvicornWorker -b <span class="m">0</span>.0.0.0:7589 --certfile<span class="o">=</span>cert.pem --keyfile<span class="o">=</span>privkey.pem +<pre><span></span><code>gunicorn<span class="w"> </span>api:app<span class="w"> </span>-k<span class="w"> </span>uvicorn.workers.UvicornWorker<span class="w"> </span>-b<span class="w"> </span><span class="m">0</span>.0.0.0:7589<span class="w"> </span>--certfile<span class="o">=</span>cert.pem<span class="w"> </span>--keyfile<span class="o">=</span>privkey.pem </code></pre> </div> diff --git a/docs/posts/2020-12-1-HTML-JS-RSS-Feed.html b/docs/posts/2020-12-1-HTML-JS-RSS-Feed.html index 84c6840..cf1936f 100644 --- a/docs/posts/2020-12-1-HTML-JS-RSS-Feed.html +++ b/docs/posts/2020-12-1-HTML-JS-RSS-Feed.html @@ -80,176 +80,176 @@ <span class="p"></</span><span class="nt">main</span><span class="p">></span> <span class="p"><</span><span class="nt">script</span> <span class="na">src</span><span class="o">=</span><span class="s">"https://gitcdn.xyz/repo/rbren/rss-parser/master/dist/rss-parser.js"</span><span class="p">></</span><span class="nt">script</span><span class="p">></span> -<span class="p"><</span><span class="nt">script</span><span class="p">></span><span class="w"></span> - -<span class="kd">const</span><span class="w"> </span><span class="nx">feeds</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="s2">"BuzzFeed - India"</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="s2">"link"</span><span class="o">:</span><span class="s2">"https://www.buzzfeed.com/in.xml"</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="s2">"summary"</span><span class="o">:</span><span class="kc">true</span><span class="w"></span> -<span class="w"> </span><span class="p">},</span><span class="w"></span> -<span class="w"> </span><span class="s2">"New Yorker"</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="s2">"link"</span><span class="o">:</span><span class="s2">"http://www.newyorker.com/feed/news"</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="p">},</span><span class="w"></span> -<span class="w"> </span><span class="s2">"Vox"</span><span class="o">:</span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="s2">"link"</span><span class="o">:</span><span class="s2">"https://www.vox.com/rss/index.xml"</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="s2">"limit"</span><span class="o">:</span><span class="w"> </span><span class="mf">3</span><span class="w"></span> -<span class="w"> </span><span class="p">},</span><span class="w"></span> -<span class="w"> </span><span class="s2">"r/Jokes"</span><span class="o">:</span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="s2">"link"</span><span class="o">:</span><span class="s2">"https://reddit.com/r/Jokes/hot/.rss?sort=hot"</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="s2">"ignore"</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"repost"</span><span class="p">,</span><span class="s2">"discord"</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="p">}</span><span class="w"></span> - -<span class="kd">const</span><span class="w"> </span><span class="nx">config_extra</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="s2">"Responsive-Images"</span><span class="o">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w"></span> -<span class="s2">"direct-link"</span><span class="o">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w"></span> -<span class="s2">"show-date"</span><span class="o">:</span><span class="kc">false</span><span class="p">,</span><span class="w"></span> -<span class="s2">"left-column"</span><span class="o">:</span><span class="kc">false</span><span class="p">,</span><span class="w"></span> -<span class="s2">"defaults"</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="s2">"limit"</span><span class="o">:</span><span class="w"> </span><span class="mf">5</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="s2">"summary"</span><span class="o">:</span><span class="w"> </span><span class="kc">true</span><span class="w"></span> -<span class="p">}</span><span class="w"></span> -<span class="p">}</span><span class="w"></span> - -<span class="kd">const</span><span class="w"> </span><span class="nx">CORS_PROXY</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"https://cors-anywhere.herokuapp.com/"</span><span class="w"></span> - -<span class="kd">var</span><span class="w"> </span><span class="nx">contents_title</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"h2"</span><span class="p">)</span><span class="w"></span> -<span class="nx">contents_title</span><span class="p">.</span><span class="nx">textContent</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"Contents"</span><span class="w"></span> -<span class="nx">contents_title</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"pb-1"</span><span class="p">)</span><span class="w"></span> -<span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s2">"contents"</span><span class="p">).</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">contents_title</span><span class="p">)</span><span class="w"></span> - -<span class="k">async</span><span class="w"> </span><span class="kd">function</span><span class="w"> </span><span class="nx">myfunc</span><span class="p">(</span><span class="nx">key</span><span class="p">){</span><span class="w"></span> - -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">count_lim</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">feeds</span><span class="p">[</span><span class="nx">key</span><span class="p">][</span><span class="s2">"limit"</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">count_lim</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="nx">count_lim</span><span class="w"> </span><span class="o">===</span><span class="w"> </span><span class="kc">undefined</span><span class="p">)</span><span class="w"> </span><span class="o">?</span><span class="w"> </span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">"defaults"</span><span class="p">][</span><span class="s2">"limit"</span><span class="p">]</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="nx">count_lim</span><span class="w"></span> - -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">show_summary</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">feeds</span><span class="p">[</span><span class="nx">key</span><span class="p">][</span><span class="s2">"summary"</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">show_summary</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="nx">show_summary</span><span class="w"> </span><span class="o">===</span><span class="w"> </span><span class="kc">undefined</span><span class="p">)</span><span class="w"> </span><span class="o">?</span><span class="w"> </span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">"defaults"</span><span class="p">][</span><span class="s2">"summary"</span><span class="p">]</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="nx">show_summary</span><span class="w"></span> - -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">ignore_tags</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">feeds</span><span class="p">[</span><span class="nx">key</span><span class="p">][</span><span class="s2">"ignore"</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">ignore_tags</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="nx">ignore_tags</span><span class="w"> </span><span class="o">===</span><span class="w"> </span><span class="kc">undefined</span><span class="p">)</span><span class="w"> </span><span class="o">?</span><span class="w"> </span><span class="p">[]</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="nx">ignore_tags</span><span class="w"></span> - -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">contents</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"a"</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="nx">contents</span><span class="p">.</span><span class="nx">href</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"#"</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">key</span><span class="w"></span> -<span class="w"> </span><span class="nx">contents</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"list-group-item"</span><span class="p">,</span><span class="s2">"list-group-item-action"</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="nx">contents</span><span class="p">.</span><span class="nx">textContent</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">key</span><span class="w"></span> -<span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s2">"contents"</span><span class="p">).</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">contents</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">feed_div</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"div"</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="nx">feed_div</span><span class="p">.</span><span class="nx">id</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">key</span><span class="w"></span> -<span class="w"> </span><span class="nx">feed_div</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="s2">"id"</span><span class="p">,</span><span class="w"> </span><span class="nx">key</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">title</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"h2"</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="nx">title</span><span class="p">.</span><span class="nx">textContent</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"From "</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">key</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="nx">title</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"pb-1"</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="nx">feed_div</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">title</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s2">"feed"</span><span class="p">).</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">feed_div</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">parser</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="ow">new</span><span class="w"> </span><span class="nx">RSSParser</span><span class="p">();</span><span class="w"></span> -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">countPosts</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="w"></span> -<span class="w"> </span><span class="nx">parser</span><span class="p">.</span><span class="nx">parseURL</span><span class="p">(</span><span class="nx">CORS_PROXY</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">feeds</span><span class="p">[</span><span class="nx">key</span><span class="p">][</span><span class="s2">"link"</span><span class="p">],</span><span class="w"> </span><span class="kd">function</span><span class="p">(</span><span class="nx">err</span><span class="p">,</span><span class="w"> </span><span class="nx">feed</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">err</span><span class="p">)</span><span class="w"> </span><span class="k">throw</span><span class="w"> </span><span class="nx">err</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="nx">feed</span><span class="p">.</span><span class="nx">items</span><span class="p">.</span><span class="nx">forEach</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">entry</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">countPosts</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">count_lim</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">skip</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">false</span><span class="w"></span> -<span class="w"> </span><span class="k">for</span><span class="p">(</span><span class="kd">var</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">ignore_tags</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">entry</span><span class="p">.</span><span class="nx">title</span><span class="p">.</span><span class="nx">includes</span><span class="p">(</span><span class="nx">ignore_tags</span><span class="p">[</span><span class="nx">i</span><span class="p">])){</span><span class="w"></span> -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">skip</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">true</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">entry</span><span class="p">.</span><span class="nx">content</span><span class="p">.</span><span class="nx">includes</span><span class="p">(</span><span class="nx">ignore_tags</span><span class="p">[</span><span class="nx">i</span><span class="p">])){</span><span class="w"></span> -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">skip</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">true</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> - -<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="o">!</span><span class="nx">skip</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">node</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"div"</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="nx">node</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"card"</span><span class="p">,</span><span class="s2">"mb-3"</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">row</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"div"</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="nx">row</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"row"</span><span class="p">,</span><span class="s2">"no-gutters"</span><span class="p">)</span><span class="w"></span> - -<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">"left-column"</span><span class="p">]){</span><span class="w"></span> -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">left_col</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"div"</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="nx">left_col</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"col-md-2"</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">left_col_body</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"div"</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="nx">left_col_body</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"card-body"</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> - -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">right_col</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"div"</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">"left-column"</span><span class="p">]){</span><span class="w"></span> -<span class="w"> </span><span class="nx">right_col</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"col-md-10"</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">node_title</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"h5"</span><span class="p">)</span><span class="w"></span> - -<span class="w"> </span><span class="nx">node_title</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"card-header"</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="nx">node_title</span><span class="p">.</span><span class="nx">innerHTML</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">entry</span><span class="p">.</span><span class="nx">title</span><span class="w"></span> - -<span class="w"> </span><span class="nx">node_body</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"div"</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="nx">node_body</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"card-body"</span><span class="p">)</span><span class="w"></span> - -<span class="w"> </span><span class="nx">node_content</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"p"</span><span class="p">)</span><span class="w"></span> - -<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">show_summary</span><span class="p">){</span><span class="w"></span> -<span class="w"> </span><span class="nx">node_content</span><span class="p">.</span><span class="nx">innerHTML</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">entry</span><span class="p">.</span><span class="nx">content</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="w"> </span><span class="nx">node_content</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"card-text"</span><span class="p">)</span><span class="w"></span> - -<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">"direct-link"</span><span class="p">]){</span><span class="w"></span> -<span class="w"> </span><span class="nx">node_link</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"p"</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="nx">node_link</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"card-text"</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="nx">node_link</span><span class="p">.</span><span class="nx">innerHTML</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"<b>Link:</b> <a href='"</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">entry</span><span class="p">.</span><span class="nx">link</span><span class="w"> </span><span class="o">+</span><span class="s2">"'>Direct Link</a>"</span><span class="w"></span> -<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">"left-column"</span><span class="p">]){</span><span class="w"></span> -<span class="w"> </span><span class="nx">left_col_body</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">node_link</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="nx">node_content</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">node_link</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> - -<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">"show-date"</span><span class="p">]){</span><span class="w"></span> -<span class="w"> </span><span class="nx">node_date</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"p"</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="nx">node_date</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"card-text"</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="nx">node_date</span><span class="p">.</span><span class="nx">innerHTML</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"<p><b>Date: </b>"</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">entry</span><span class="p">.</span><span class="nx">pubDate</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="s2">"</p>"</span><span class="w"></span> -<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">"left-column"</span><span class="p">]){</span><span class="w"></span> -<span class="w"> </span><span class="nx">left_col_body</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">node_date</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="nx">node_content</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">node_date</span><span class="p">)</span><span class="w"></span> - -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> - -<span class="w"> </span><span class="nx">node</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">node_title</span><span class="p">)</span><span class="w"></span> - -<span class="w"> </span><span class="nx">node_body</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">node_content</span><span class="p">)</span><span class="w"></span> - -<span class="w"> </span><span class="nx">right_col</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">node_body</span><span class="p">)</span><span class="w"></span> - -<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">"left-column"</span><span class="p">]){</span><span class="w"></span> -<span class="w"> </span><span class="nx">left_col</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">left_col_body</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="nx">row</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">left_col</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> - -<span class="w"> </span><span class="nx">row</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">right_col</span><span class="p">)</span><span class="w"></span> - -<span class="w"> </span><span class="nx">node</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">row</span><span class="p">)</span><span class="w"></span> - -<span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="nx">key</span><span class="p">).</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">node</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="nx">countPosts</span><span class="o">+=</span><span class="mf">1</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="w"> </span><span class="p">})</span><span class="w"></span> - -<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">"Responsive-Images"</span><span class="p">]){</span><span class="w"></span> -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">inputs</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementsByTagName</span><span class="p">(</span><span class="s1">'img'</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="k">for</span><span class="p">(</span><span class="kd">var</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">inputs</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="nx">inputs</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"img-fluid"</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> - -<span class="w"> </span><span class="p">})</span><span class="w"></span> - -<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="kc">true</span><span class="w"></span> -<span class="p">}</span><span class="w"></span> -<span class="p">(</span><span class="k">async</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="k">for</span><span class="p">(</span><span class="kd">var</span><span class="w"> </span><span class="nx">key</span><span class="w"> </span><span class="ow">in</span><span class="w"> </span><span class="nx">feeds</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">result</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">await</span><span class="w"> </span><span class="nx">myfunc</span><span class="p">(</span><span class="nx">key</span><span class="p">);</span><span class="w"></span> -<span class="p">}})();</span><span class="w"></span> +<span class="p"><</span><span class="nt">script</span><span class="p">></span> + +<span class="kd">const</span><span class="w"> </span><span class="nx">feeds</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="s2">"BuzzFeed - India"</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="s2">"link"</span><span class="o">:</span><span class="s2">"https://www.buzzfeed.com/in.xml"</span><span class="p">,</span> +<span class="w"> </span><span class="s2">"summary"</span><span class="o">:</span><span class="kc">true</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="s2">"New Yorker"</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="s2">"link"</span><span class="o">:</span><span class="s2">"http://www.newyorker.com/feed/news"</span><span class="p">,</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="s2">"Vox"</span><span class="o">:</span><span class="p">{</span> +<span class="w"> </span><span class="s2">"link"</span><span class="o">:</span><span class="s2">"https://www.vox.com/rss/index.xml"</span><span class="p">,</span> +<span class="w"> </span><span class="s2">"limit"</span><span class="o">:</span><span class="w"> </span><span class="mf">3</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="s2">"r/Jokes"</span><span class="o">:</span><span class="p">{</span> +<span class="w"> </span><span class="s2">"link"</span><span class="o">:</span><span class="s2">"https://reddit.com/r/Jokes/hot/.rss?sort=hot"</span><span class="p">,</span> +<span class="w"> </span><span class="s2">"ignore"</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"repost"</span><span class="p">,</span><span class="s2">"discord"</span><span class="p">]</span> +<span class="w"> </span><span class="p">}</span> +<span class="p">}</span> + +<span class="kd">const</span><span class="w"> </span><span class="nx">config_extra</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span> +<span class="s2">"Responsive-Images"</span><span class="o">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span> +<span class="s2">"direct-link"</span><span class="o">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span> +<span class="s2">"show-date"</span><span class="o">:</span><span class="kc">false</span><span class="p">,</span> +<span class="s2">"left-column"</span><span class="o">:</span><span class="kc">false</span><span class="p">,</span> +<span class="s2">"defaults"</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="s2">"limit"</span><span class="o">:</span><span class="w"> </span><span class="mf">5</span><span class="p">,</span> +<span class="w"> </span><span class="s2">"summary"</span><span class="o">:</span><span class="w"> </span><span class="kc">true</span> +<span class="p">}</span> +<span class="p">}</span> + +<span class="kd">const</span><span class="w"> </span><span class="nx">CORS_PROXY</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"https://cors-anywhere.herokuapp.com/"</span> + +<span class="kd">var</span><span class="w"> </span><span class="nx">contents_title</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"h2"</span><span class="p">)</span> +<span class="nx">contents_title</span><span class="p">.</span><span class="nx">textContent</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"Contents"</span> +<span class="nx">contents_title</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"pb-1"</span><span class="p">)</span> +<span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s2">"contents"</span><span class="p">).</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">contents_title</span><span class="p">)</span> + +<span class="k">async</span><span class="w"> </span><span class="kd">function</span><span class="w"> </span><span class="nx">myfunc</span><span class="p">(</span><span class="nx">key</span><span class="p">){</span> + +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">count_lim</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">feeds</span><span class="p">[</span><span class="nx">key</span><span class="p">][</span><span class="s2">"limit"</span><span class="p">]</span> +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">count_lim</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="nx">count_lim</span><span class="w"> </span><span class="o">===</span><span class="w"> </span><span class="kc">undefined</span><span class="p">)</span><span class="w"> </span><span class="o">?</span><span class="w"> </span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">"defaults"</span><span class="p">][</span><span class="s2">"limit"</span><span class="p">]</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="nx">count_lim</span> + +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">show_summary</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">feeds</span><span class="p">[</span><span class="nx">key</span><span class="p">][</span><span class="s2">"summary"</span><span class="p">]</span> +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">show_summary</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="nx">show_summary</span><span class="w"> </span><span class="o">===</span><span class="w"> </span><span class="kc">undefined</span><span class="p">)</span><span class="w"> </span><span class="o">?</span><span class="w"> </span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">"defaults"</span><span class="p">][</span><span class="s2">"summary"</span><span class="p">]</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="nx">show_summary</span> + +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">ignore_tags</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">feeds</span><span class="p">[</span><span class="nx">key</span><span class="p">][</span><span class="s2">"ignore"</span><span class="p">]</span> +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">ignore_tags</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="nx">ignore_tags</span><span class="w"> </span><span class="o">===</span><span class="w"> </span><span class="kc">undefined</span><span class="p">)</span><span class="w"> </span><span class="o">?</span><span class="w"> </span><span class="p">[]</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="nx">ignore_tags</span> + +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">contents</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"a"</span><span class="p">)</span> +<span class="w"> </span><span class="nx">contents</span><span class="p">.</span><span class="nx">href</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"#"</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">key</span> +<span class="w"> </span><span class="nx">contents</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"list-group-item"</span><span class="p">,</span><span class="s2">"list-group-item-action"</span><span class="p">)</span> +<span class="w"> </span><span class="nx">contents</span><span class="p">.</span><span class="nx">textContent</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">key</span> +<span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s2">"contents"</span><span class="p">).</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">contents</span><span class="p">)</span> +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">feed_div</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"div"</span><span class="p">)</span> +<span class="w"> </span><span class="nx">feed_div</span><span class="p">.</span><span class="nx">id</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">key</span> +<span class="w"> </span><span class="nx">feed_div</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="s2">"id"</span><span class="p">,</span><span class="w"> </span><span class="nx">key</span><span class="p">);</span> +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">title</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"h2"</span><span class="p">);</span> +<span class="w"> </span><span class="nx">title</span><span class="p">.</span><span class="nx">textContent</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"From "</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">key</span><span class="p">;</span> +<span class="w"> </span><span class="nx">title</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"pb-1"</span><span class="p">)</span> +<span class="w"> </span><span class="nx">feed_div</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">title</span><span class="p">)</span> +<span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s2">"feed"</span><span class="p">).</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">feed_div</span><span class="p">)</span> +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">parser</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="ow">new</span><span class="w"> </span><span class="nx">RSSParser</span><span class="p">();</span> +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">countPosts</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span> +<span class="w"> </span><span class="nx">parser</span><span class="p">.</span><span class="nx">parseURL</span><span class="p">(</span><span class="nx">CORS_PROXY</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">feeds</span><span class="p">[</span><span class="nx">key</span><span class="p">][</span><span class="s2">"link"</span><span class="p">],</span><span class="w"> </span><span class="kd">function</span><span class="p">(</span><span class="nx">err</span><span class="p">,</span><span class="w"> </span><span class="nx">feed</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">err</span><span class="p">)</span><span class="w"> </span><span class="k">throw</span><span class="w"> </span><span class="nx">err</span><span class="p">;</span> +<span class="w"> </span><span class="nx">feed</span><span class="p">.</span><span class="nx">items</span><span class="p">.</span><span class="nx">forEach</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">entry</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">countPosts</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">count_lim</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> + +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">skip</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">false</span> +<span class="w"> </span><span class="k">for</span><span class="p">(</span><span class="kd">var</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">ignore_tags</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">entry</span><span class="p">.</span><span class="nx">title</span><span class="p">.</span><span class="nx">includes</span><span class="p">(</span><span class="nx">ignore_tags</span><span class="p">[</span><span class="nx">i</span><span class="p">])){</span> +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">skip</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">true</span> +<span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">entry</span><span class="p">.</span><span class="nx">content</span><span class="p">.</span><span class="nx">includes</span><span class="p">(</span><span class="nx">ignore_tags</span><span class="p">[</span><span class="nx">i</span><span class="p">])){</span> +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">skip</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">true</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="p">}</span> + +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="o">!</span><span class="nx">skip</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> + +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">node</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"div"</span><span class="p">);</span> +<span class="w"> </span><span class="nx">node</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"card"</span><span class="p">,</span><span class="s2">"mb-3"</span><span class="p">);</span> +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">row</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"div"</span><span class="p">)</span> +<span class="w"> </span><span class="nx">row</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"row"</span><span class="p">,</span><span class="s2">"no-gutters"</span><span class="p">)</span> + +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">"left-column"</span><span class="p">]){</span> +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">left_col</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"div"</span><span class="p">)</span> +<span class="w"> </span><span class="nx">left_col</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"col-md-2"</span><span class="p">)</span> +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">left_col_body</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"div"</span><span class="p">)</span> +<span class="w"> </span><span class="nx">left_col_body</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"card-body"</span><span class="p">)</span> +<span class="w"> </span><span class="p">}</span> + +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">right_col</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"div"</span><span class="p">)</span> +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">"left-column"</span><span class="p">]){</span> +<span class="w"> </span><span class="nx">right_col</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"col-md-10"</span><span class="p">)</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">node_title</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"h5"</span><span class="p">)</span> + +<span class="w"> </span><span class="nx">node_title</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"card-header"</span><span class="p">)</span> +<span class="w"> </span><span class="nx">node_title</span><span class="p">.</span><span class="nx">innerHTML</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">entry</span><span class="p">.</span><span class="nx">title</span> + +<span class="w"> </span><span class="nx">node_body</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"div"</span><span class="p">)</span> +<span class="w"> </span><span class="nx">node_body</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"card-body"</span><span class="p">)</span> + +<span class="w"> </span><span class="nx">node_content</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"p"</span><span class="p">)</span> + +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">show_summary</span><span class="p">){</span> +<span class="w"> </span><span class="nx">node_content</span><span class="p">.</span><span class="nx">innerHTML</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">entry</span><span class="p">.</span><span class="nx">content</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="nx">node_content</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"card-text"</span><span class="p">)</span> + +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">"direct-link"</span><span class="p">]){</span> +<span class="w"> </span><span class="nx">node_link</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"p"</span><span class="p">)</span> +<span class="w"> </span><span class="nx">node_link</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"card-text"</span><span class="p">)</span> +<span class="w"> </span><span class="nx">node_link</span><span class="p">.</span><span class="nx">innerHTML</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"<b>Link:</b> <a href='"</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">entry</span><span class="p">.</span><span class="nx">link</span><span class="w"> </span><span class="o">+</span><span class="s2">"'>Direct Link</a>"</span> +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">"left-column"</span><span class="p">]){</span> +<span class="w"> </span><span class="nx">left_col_body</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">node_link</span><span class="p">)</span> +<span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">node_content</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">node_link</span><span class="p">)</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="p">}</span> + +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">"show-date"</span><span class="p">]){</span> +<span class="w"> </span><span class="nx">node_date</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"p"</span><span class="p">)</span> +<span class="w"> </span><span class="nx">node_date</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"card-text"</span><span class="p">)</span> +<span class="w"> </span><span class="nx">node_date</span><span class="p">.</span><span class="nx">innerHTML</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"<p><b>Date: </b>"</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">entry</span><span class="p">.</span><span class="nx">pubDate</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="s2">"</p>"</span> +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">"left-column"</span><span class="p">]){</span> +<span class="w"> </span><span class="nx">left_col_body</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">node_date</span><span class="p">)</span> +<span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">node_content</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">node_date</span><span class="p">)</span> + +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="p">}</span> + +<span class="w"> </span><span class="nx">node</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">node_title</span><span class="p">)</span> + +<span class="w"> </span><span class="nx">node_body</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">node_content</span><span class="p">)</span> + +<span class="w"> </span><span class="nx">right_col</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">node_body</span><span class="p">)</span> + +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">"left-column"</span><span class="p">]){</span> +<span class="w"> </span><span class="nx">left_col</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">left_col_body</span><span class="p">)</span> +<span class="w"> </span><span class="nx">row</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">left_col</span><span class="p">)</span> +<span class="w"> </span><span class="p">}</span> + +<span class="w"> </span><span class="nx">row</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">right_col</span><span class="p">)</span> + +<span class="w"> </span><span class="nx">node</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">row</span><span class="p">)</span> + +<span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="nx">key</span><span class="p">).</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">node</span><span class="p">)</span> +<span class="w"> </span><span class="nx">countPosts</span><span class="o">+=</span><span class="mf">1</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="p">})</span> + +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">"Responsive-Images"</span><span class="p">]){</span> +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">inputs</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementsByTagName</span><span class="p">(</span><span class="s1">'img'</span><span class="p">)</span> +<span class="w"> </span><span class="k">for</span><span class="p">(</span><span class="kd">var</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">inputs</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">inputs</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">"img-fluid"</span><span class="p">)</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="p">}</span> + +<span class="w"> </span><span class="p">})</span> + +<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="kc">true</span> +<span class="p">}</span> +<span class="p">(</span><span class="k">async</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="p">{</span> +<span class="k">for</span><span class="p">(</span><span class="kd">var</span><span class="w"> </span><span class="nx">key</span><span class="w"> </span><span class="ow">in</span><span class="w"> </span><span class="nx">feeds</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">result</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">await</span><span class="w"> </span><span class="nx">myfunc</span><span class="p">(</span><span class="nx">key</span><span class="p">);</span> +<span class="p">}})();</span> <span class="p"></</span><span class="nt">script</span><span class="p">></span> <span class="p"><</span><span class="nt">noscript</span><span class="p">></span>Uh Oh! Your browser does not support JavaScript or JavaScript is currently disabled. Please enable JavaScript or switch to a different browser.<span class="p"></</span><span class="nt">noscript</span><span class="p">></span> diff --git a/docs/posts/2021-06-27-Crude-ML-AI-Powered-Chatbot-Swift.html b/docs/posts/2021-06-27-Crude-ML-AI-Powered-Chatbot-Swift.html index c29bb8c..887b617 100644 --- a/docs/posts/2021-06-27-Crude-ML-AI-Powered-Chatbot-Swift.html +++ b/docs/posts/2021-06-27-Crude-ML-AI-Powered-Chatbot-Swift.html @@ -103,20 +103,20 @@ I created a sample JSON with only 3 examples (I know, very less, but works for a <p><img src="/assets/posts/swift-chatbot/drugs-json.png" alt="Screenshot of Sample Dataset" /></p> <div class="codehilite"> -<pre><span></span><code><span class="p">[</span><span class="w"></span> -<span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="nt">"tokens"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"Tell"</span><span class="p">,</span><span class="s2">"me"</span><span class="p">,</span><span class="s2">"about"</span><span class="p">,</span><span class="s2">"the"</span><span class="p">,</span><span class="s2">"drug"</span><span class="p">,</span><span class="s2">"Aspirin"</span><span class="p">,</span><span class="s2">"."</span><span class="p">],</span><span class="w"></span> -<span class="w"> </span><span class="nt">"labels"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"COMPOUND"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span><span class="p">},</span><span class="w"></span> -<span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="nt">"tokens"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"Please"</span><span class="p">,</span><span class="s2">"tell"</span><span class="p">,</span><span class="s2">"me"</span><span class="p">,</span><span class="s2">"information"</span><span class="p">,</span><span class="s2">"about"</span><span class="p">,</span><span class="s2">"the"</span><span class="p">,</span><span class="s2">"compound"</span><span class="p">,</span><span class="s2">"salicylic"</span><span class="p">,</span><span class="s2">"acid"</span><span class="p">,</span><span class="s2">"."</span><span class="p">],</span><span class="w"></span> -<span class="w"> </span><span class="nt">"labels"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"COMPOUND"</span><span class="p">,</span><span class="s2">"COMPOUND"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span><span class="p">},</span><span class="w"></span> -<span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="nt">"tokens"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"Information"</span><span class="p">,</span><span class="s2">"about"</span><span class="p">,</span><span class="s2">"the"</span><span class="p">,</span><span class="s2">"compound"</span><span class="p">,</span><span class="s2">"Ibuprofen"</span><span class="p">,</span><span class="s2">"please"</span><span class="p">,</span><span class="s2">"."</span><span class="p">],</span><span class="w"></span> -<span class="w"> </span><span class="nt">"labels"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"COMPOUND"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="p">]</span><span class="w"></span> +<pre><span></span><code><span class="p">[</span> +<span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nt">"tokens"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"Tell"</span><span class="p">,</span><span class="s2">"me"</span><span class="p">,</span><span class="s2">"about"</span><span class="p">,</span><span class="s2">"the"</span><span class="p">,</span><span class="s2">"drug"</span><span class="p">,</span><span class="s2">"Aspirin"</span><span class="p">,</span><span class="s2">"."</span><span class="p">],</span> +<span class="w"> </span><span class="nt">"labels"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"COMPOUND"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">]</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nt">"tokens"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"Please"</span><span class="p">,</span><span class="s2">"tell"</span><span class="p">,</span><span class="s2">"me"</span><span class="p">,</span><span class="s2">"information"</span><span class="p">,</span><span class="s2">"about"</span><span class="p">,</span><span class="s2">"the"</span><span class="p">,</span><span class="s2">"compound"</span><span class="p">,</span><span class="s2">"salicylic"</span><span class="p">,</span><span class="s2">"acid"</span><span class="p">,</span><span class="s2">"."</span><span class="p">],</span> +<span class="w"> </span><span class="nt">"labels"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"COMPOUND"</span><span class="p">,</span><span class="s2">"COMPOUND"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">]</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nt">"tokens"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"Information"</span><span class="p">,</span><span class="s2">"about"</span><span class="p">,</span><span class="s2">"the"</span><span class="p">,</span><span class="s2">"compound"</span><span class="p">,</span><span class="s2">"Ibuprofen"</span><span class="p">,</span><span class="s2">"please"</span><span class="p">,</span><span class="s2">"."</span><span class="p">],</span> +<span class="w"> </span><span class="nt">"labels"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"COMPOUND"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">,</span><span class="s2">"NONE"</span><span class="p">]</span> +<span class="w"> </span><span class="p">}</span> +<span class="p">]</span> </code></pre> </div> diff --git a/docs/posts/2022-08-05-Why-You-No-Host.html b/docs/posts/2022-08-05-Why-You-No-Host.html index 208f6dd..c4a2295 100644 --- a/docs/posts/2022-08-05-Why-You-No-Host.html +++ b/docs/posts/2022-08-05-Why-You-No-Host.html @@ -79,7 +79,7 @@ </ul></li> <li>How about account suspensions without any prior notice? <ul> -<li><a rel="noopener" target="_blank" href="https://hn.algolia.com/?dateRange=all&page=0&prefix=true&query=account%20suspended&sort=byPopularity&type=story">Hacker News stories with “account suspended“</a></li> +<li><a rel="noopener" target="_blank" href="https://hn.algolia.com/?dateRange=all&page=0&prefix=true&query=account%20suspended&sort=byPopularity&type=story">Hacker News stories with “account suspended“</a></li> </ul></li> <li>Do you value security and privacy?</li> <li>Or, do you want a new hobby?</li> diff --git a/docs/posts/2023-02-08-Interact-with-siri-from-the-terminal.html b/docs/posts/2023-02-08-Interact-with-siri-from-the-terminal.html index 2db536b..9b8973b 100644 --- a/docs/posts/2023-02-08-Interact-with-siri-from-the-terminal.html +++ b/docs/posts/2023-02-08-Interact-with-siri-from-the-terminal.html @@ -104,7 +104,7 @@ <span class="k">def</span> <span class="nf">execute_command</span><span class="p">(</span><span class="n">command_text</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> - <span class="sd">"""Execute a Siri command."""</span> +<span class="w"> </span><span class="sd">"""Execute a Siri command."""</span> <span class="n">script</span> <span class="o">=</span> <span class="n">applescript</span><span class="o">.</span><span class="n">AppleScript</span><span class="p">(</span><span class="sa">f</span><span class="s2">"""</span> <span class="s2"> tell application "System Events" to tell the front menu bar of process "SystemUIServer"</span> @@ -141,8 +141,8 @@ <p>Usage:</p> <div class="codehilite"> -<pre><span></span><code>python3 main.py <span class="s2">"play some taylor swift"</span> -python3 main.py <span class="s2">"turn off the lights and play some music"</span> --openai +<pre><span></span><code>python3<span class="w"> </span>main.py<span class="w"> </span><span class="s2">"play some taylor swift"</span> +python3<span class="w"> </span>main.py<span class="w"> </span><span class="s2">"turn off the lights and play some music"</span><span class="w"> </span>--openai </code></pre> </div> @@ -179,7 +179,7 @@ python3 main.py <span class="s2">"turn off the lights and play some music&q <pre><span></span><code><span class="kn">import</span> <span class="nn">applescript</span> <span class="k">def</span> <span class="nf">execute_command</span><span class="p">(</span><span class="n">command_text</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> - <span class="sd">"""Execute a Siri command."""</span> +<span class="w"> </span><span class="sd">"""Execute a Siri command."""</span> <span class="n">script</span> <span class="o">=</span> <span class="n">applescript</span><span class="o">.</span><span class="n">AppleScript</span><span class="p">(</span><span class="sa">f</span><span class="s2">"""</span> <span class="s2"> tell application "System Events" to tell the front menu bar of process "SystemUIServer"</span> diff --git a/docs/posts/2023-04-30-n-body-simulation.html b/docs/posts/2023-04-30-n-body-simulation.html index cb0bf6c..e12380a 100644 --- a/docs/posts/2023-04-30-n-body-simulation.html +++ b/docs/posts/2023-04-30-n-body-simulation.html @@ -89,46 +89,46 @@ <pre><span></span><code><span class="cm">/*</span> <span class="cm"> * Earth - Sun Orbit Plot</span> <span class="cm"> * Taken from Numerics tutorial</span> -<span class="cm"> */</span><span class="w"></span> - -<span class="kd">const</span><span class="w"> </span><span class="nx">G</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">6.67e-11</span><span class="p">;</span><span class="w"></span> -<span class="kd">const</span><span class="w"> </span><span class="nx">Msun</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">2e30</span><span class="p">;</span><span class="w"></span> -<span class="kd">const</span><span class="w"> </span><span class="nx">AU</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">1.5e11</span><span class="p">;</span><span class="w"></span> -<span class="kd">const</span><span class="w"> </span><span class="nx">v0</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sqrt</span><span class="p">(</span><span class="nx">G</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">Msun</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nx">AU</span><span class="p">);</span><span class="w"> </span><span class="c1">// SI</span><span class="w"></span> - -<span class="kd">function</span><span class="w"> </span><span class="nx">dR</span><span class="p">(</span><span class="nx">r</span><span class="p">,</span><span class="w"> </span><span class="nx">v</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">dv</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="nx">G</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">Msun</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">pow</span><span class="p">(</span><span class="nx">r</span><span class="p">[</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">**</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">r</span><span class="p">[</span><span class="mf">1</span><span class="p">]</span><span class="w"> </span><span class="o">**</span><span class="w"> </span><span class="mf">2</span><span class="p">,</span><span class="w"> </span><span class="mf">3</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">2</span><span class="p">)</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">r</span><span class="p">[</span><span class="mf">0</span><span class="p">],</span><span class="w"> </span><span class="o">-</span><span class="nx">G</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">Msun</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">pow</span><span class="p">(</span><span class="nx">r</span><span class="p">[</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">**</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">r</span><span class="p">[</span><span class="mf">1</span><span class="p">]</span><span class="w"> </span><span class="o">**</span><span class="w"> </span><span class="mf">2</span><span class="p">,</span><span class="w"> </span><span class="mf">3</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">2</span><span class="p">)</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">r</span><span class="p">[</span><span class="mf">1</span><span class="p">]];</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">dr</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[...</span><span class="nx">v</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="p">[</span><span class="nx">dr</span><span class="p">,</span><span class="w"> </span><span class="nx">dv</span><span class="p">];</span><span class="w"></span> -<span class="p">}</span><span class="w"></span> - -<span class="c1">// initialize system</span><span class="w"></span> -<span class="kd">let</span><span class="w"> </span><span class="nx">r</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="nx">AU</span><span class="p">,</span><span class="w"> </span><span class="mf">0</span><span class="p">];</span><span class="w"></span> -<span class="kd">const</span><span class="w"> </span><span class="nx">theta</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">atan2</span><span class="p">(</span><span class="nx">r</span><span class="p">[</span><span class="mf">1</span><span class="p">],</span><span class="w"> </span><span class="nx">r</span><span class="p">[</span><span class="mf">0</span><span class="p">]);</span><span class="w"></span> -<span class="kd">let</span><span class="w"> </span><span class="nx">v</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="nx">v0</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sin</span><span class="p">(</span><span class="nx">theta</span><span class="p">),</span><span class="w"> </span><span class="nx">v0</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">cos</span><span class="p">(</span><span class="nx">theta</span><span class="p">)];</span><span class="w"></span> - -<span class="kd">const</span><span class="w"> </span><span class="nx">t</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Array</span><span class="p">.</span><span class="kr">from</span><span class="p">({</span><span class="w"> </span><span class="nx">length</span><span class="o">:</span><span class="w"> </span><span class="mf">1001</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="p">(</span><span class="nx">_</span><span class="p">,</span><span class="w"> </span><span class="nx">i</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">100</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mf">0.0</span><span class="p">);</span><span class="w"> </span><span class="c1">// years</span><span class="w"></span> -<span class="kd">const</span><span class="w"> </span><span class="nx">yearSec</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">365</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">24</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">3600</span><span class="p">;</span><span class="w"></span> -<span class="kd">const</span><span class="w"> </span><span class="nx">dt</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="nx">t</span><span class="p">[</span><span class="mf">1</span><span class="p">]</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">t</span><span class="p">[</span><span class="mf">0</span><span class="p">])</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">yearSec</span><span class="p">;</span><span class="w"> </span><span class="c1">// s</span><span class="w"></span> -<span class="kd">const</span><span class="w"> </span><span class="nx">x4Plot</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Array</span><span class="p">.</span><span class="kr">from</span><span class="p">({</span><span class="w"> </span><span class="nx">length</span><span class="o">:</span><span class="w"> </span><span class="nx">t</span><span class="p">.</span><span class="nx">length</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="mf">0</span><span class="p">);</span><span class="w"></span> -<span class="kd">const</span><span class="w"> </span><span class="nx">y4Plot</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Array</span><span class="p">.</span><span class="kr">from</span><span class="p">({</span><span class="w"> </span><span class="nx">length</span><span class="o">:</span><span class="w"> </span><span class="nx">t</span><span class="p">.</span><span class="nx">length</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="mf">0</span><span class="p">);</span><span class="w"></span> - -<span class="c1">// integrate using RK4!</span><span class="w"></span> -<span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kd">let</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">t</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">k1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">dR</span><span class="p">(</span><span class="nx">r</span><span class="p">,</span><span class="w"> </span><span class="nx">v</span><span class="p">).</span><span class="nx">map</span><span class="p">(</span><span class="nx">x</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">x</span><span class="p">.</span><span class="nx">map</span><span class="p">(</span><span class="nx">y</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">y</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">dt</span><span class="p">));</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">k2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">dR</span><span class="p">(</span><span class="nx">r</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">ri</span><span class="p">,</span><span class="w"> </span><span class="nx">j</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">ri</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">k1</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">2</span><span class="p">),</span><span class="w"> </span><span class="nx">v</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">vi</span><span class="p">,</span><span class="w"> </span><span class="nx">j</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">vi</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">k1</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">2</span><span class="p">)).</span><span class="nx">map</span><span class="p">(</span><span class="nx">x</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">x</span><span class="p">.</span><span class="nx">map</span><span class="p">(</span><span class="nx">y</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">y</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">dt</span><span class="p">));</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">k3</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">dR</span><span class="p">(</span><span class="nx">r</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">ri</span><span class="p">,</span><span class="w"> </span><span class="nx">j</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">ri</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">k2</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">2</span><span class="p">),</span><span class="w"> </span><span class="nx">v</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">vi</span><span class="p">,</span><span class="w"> </span><span class="nx">j</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">vi</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">k2</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">2</span><span class="p">)).</span><span class="nx">map</span><span class="p">(</span><span class="nx">x</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">x</span><span class="p">.</span><span class="nx">map</span><span class="p">(</span><span class="nx">y</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">y</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">dt</span><span class="p">));</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">k4</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">dR</span><span class="p">(</span><span class="nx">r</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">ri</span><span class="p">,</span><span class="w"> </span><span class="nx">j</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">ri</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">k3</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">j</span><span class="p">]),</span><span class="w"> </span><span class="nx">v</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">vi</span><span class="p">,</span><span class="w"> </span><span class="nx">j</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">vi</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">k3</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">j</span><span class="p">])).</span><span class="nx">map</span><span class="p">(</span><span class="nx">x</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">x</span><span class="p">.</span><span class="nx">map</span><span class="p">(</span><span class="nx">y</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">y</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">dt</span><span class="p">));</span><span class="w"></span> -<span class="w"> </span><span class="nx">r</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">r</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">ri</span><span class="p">,</span><span class="w"> </span><span class="nx">j</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">ri</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="p">(</span><span class="nx">k1</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">k2</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">k3</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">k4</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">j</span><span class="p">])</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">6</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="nx">v</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">v</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">vi</span><span class="p">,</span><span class="w"> </span><span class="nx">j</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">vi</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="p">(</span><span class="nx">k1</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">k2</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">k3</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">k4</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">j</span><span class="p">])</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">6</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="nx">x4Plot</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">r</span><span class="p">[</span><span class="mf">0</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="nx">y4Plot</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">r</span><span class="p">[</span><span class="mf">1</span><span class="p">];</span><span class="w"></span> -<span class="p">}</span><span class="w"></span> - -<span class="c1">// make data for plot</span><span class="w"></span> -<span class="kd">var</span><span class="w"> </span><span class="nx">sun</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="mf">0</span><span class="p">,</span><span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="mf">0</span><span class="w"> </span><span class="p">};</span><span class="w"></span> -<span class="kd">const</span><span class="w"> </span><span class="nx">earth</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="nx">x4Plot</span><span class="p">.</span><span class="nx">map</span><span class="p">(</span><span class="nx">x</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">x</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nx">AU</span><span class="p">),</span><span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="nx">y4Plot</span><span class="p">.</span><span class="nx">map</span><span class="p">(</span><span class="nx">y</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">y</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nx">AU</span><span class="p">)</span><span class="w"> </span><span class="p">};</span><span class="w"></span> -<span class="kd">const</span><span class="w"> </span><span class="nx">circle</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="nb">Array</span><span class="p">.</span><span class="kr">from</span><span class="p">({</span><span class="w"> </span><span class="nx">length</span><span class="o">:</span><span class="w"> </span><span class="mf">1001</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="p">(</span><span class="nx">_</span><span class="p">,</span><span class="w"> </span><span class="nx">i</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">cos</span><span class="p">(</span><span class="nx">i</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">100</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">PI</span><span class="p">)),</span><span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="nb">Array</span><span class="p">.</span><span class="kr">from</span><span class="p">({</span><span class="w"> </span><span class="nx">length</span><span class="o">:</span><span class="w"> </span><span class="mf">1001</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="p">(</span><span class="nx">_</span><span class="p">,</span><span class="w"> </span><span class="nx">i</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sin</span><span class="p">(</span><span class="nx">i</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">100</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">PI</span><span class="p">))</span><span class="w"> </span><span class="p">};</span><span class="w"></span> +<span class="cm"> */</span> + +<span class="kd">const</span><span class="w"> </span><span class="nx">G</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">6.67e-11</span><span class="p">;</span> +<span class="kd">const</span><span class="w"> </span><span class="nx">Msun</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">2e30</span><span class="p">;</span> +<span class="kd">const</span><span class="w"> </span><span class="nx">AU</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">1.5e11</span><span class="p">;</span> +<span class="kd">const</span><span class="w"> </span><span class="nx">v0</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sqrt</span><span class="p">(</span><span class="nx">G</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">Msun</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nx">AU</span><span class="p">);</span><span class="w"> </span><span class="c1">// SI</span> + +<span class="kd">function</span><span class="w"> </span><span class="nx">dR</span><span class="p">(</span><span class="nx">r</span><span class="p">,</span><span class="w"> </span><span class="nx">v</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">dv</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="nx">G</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">Msun</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">pow</span><span class="p">(</span><span class="nx">r</span><span class="p">[</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">**</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">r</span><span class="p">[</span><span class="mf">1</span><span class="p">]</span><span class="w"> </span><span class="o">**</span><span class="w"> </span><span class="mf">2</span><span class="p">,</span><span class="w"> </span><span class="mf">3</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">2</span><span class="p">)</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">r</span><span class="p">[</span><span class="mf">0</span><span class="p">],</span><span class="w"> </span><span class="o">-</span><span class="nx">G</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">Msun</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">pow</span><span class="p">(</span><span class="nx">r</span><span class="p">[</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">**</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">r</span><span class="p">[</span><span class="mf">1</span><span class="p">]</span><span class="w"> </span><span class="o">**</span><span class="w"> </span><span class="mf">2</span><span class="p">,</span><span class="w"> </span><span class="mf">3</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">2</span><span class="p">)</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">r</span><span class="p">[</span><span class="mf">1</span><span class="p">]];</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">dr</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[...</span><span class="nx">v</span><span class="p">];</span> +<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="p">[</span><span class="nx">dr</span><span class="p">,</span><span class="w"> </span><span class="nx">dv</span><span class="p">];</span> +<span class="p">}</span> + +<span class="c1">// initialize system</span> +<span class="kd">let</span><span class="w"> </span><span class="nx">r</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="nx">AU</span><span class="p">,</span><span class="w"> </span><span class="mf">0</span><span class="p">];</span> +<span class="kd">const</span><span class="w"> </span><span class="nx">theta</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">atan2</span><span class="p">(</span><span class="nx">r</span><span class="p">[</span><span class="mf">1</span><span class="p">],</span><span class="w"> </span><span class="nx">r</span><span class="p">[</span><span class="mf">0</span><span class="p">]);</span> +<span class="kd">let</span><span class="w"> </span><span class="nx">v</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="nx">v0</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sin</span><span class="p">(</span><span class="nx">theta</span><span class="p">),</span><span class="w"> </span><span class="nx">v0</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">cos</span><span class="p">(</span><span class="nx">theta</span><span class="p">)];</span> + +<span class="kd">const</span><span class="w"> </span><span class="nx">t</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Array</span><span class="p">.</span><span class="kr">from</span><span class="p">({</span><span class="w"> </span><span class="nx">length</span><span class="o">:</span><span class="w"> </span><span class="mf">1001</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="p">(</span><span class="nx">_</span><span class="p">,</span><span class="w"> </span><span class="nx">i</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">100</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mf">0.0</span><span class="p">);</span><span class="w"> </span><span class="c1">// years</span> +<span class="kd">const</span><span class="w"> </span><span class="nx">yearSec</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">365</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">24</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">3600</span><span class="p">;</span> +<span class="kd">const</span><span class="w"> </span><span class="nx">dt</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="nx">t</span><span class="p">[</span><span class="mf">1</span><span class="p">]</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">t</span><span class="p">[</span><span class="mf">0</span><span class="p">])</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">yearSec</span><span class="p">;</span><span class="w"> </span><span class="c1">// s</span> +<span class="kd">const</span><span class="w"> </span><span class="nx">x4Plot</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Array</span><span class="p">.</span><span class="kr">from</span><span class="p">({</span><span class="w"> </span><span class="nx">length</span><span class="o">:</span><span class="w"> </span><span class="nx">t</span><span class="p">.</span><span class="nx">length</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="mf">0</span><span class="p">);</span> +<span class="kd">const</span><span class="w"> </span><span class="nx">y4Plot</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Array</span><span class="p">.</span><span class="kr">from</span><span class="p">({</span><span class="w"> </span><span class="nx">length</span><span class="o">:</span><span class="w"> </span><span class="nx">t</span><span class="p">.</span><span class="nx">length</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="mf">0</span><span class="p">);</span> + +<span class="c1">// integrate using RK4!</span> +<span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kd">let</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">t</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">k1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">dR</span><span class="p">(</span><span class="nx">r</span><span class="p">,</span><span class="w"> </span><span class="nx">v</span><span class="p">).</span><span class="nx">map</span><span class="p">(</span><span class="nx">x</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">x</span><span class="p">.</span><span class="nx">map</span><span class="p">(</span><span class="nx">y</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">y</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">dt</span><span class="p">));</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">k2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">dR</span><span class="p">(</span><span class="nx">r</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">ri</span><span class="p">,</span><span class="w"> </span><span class="nx">j</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">ri</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">k1</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">2</span><span class="p">),</span><span class="w"> </span><span class="nx">v</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">vi</span><span class="p">,</span><span class="w"> </span><span class="nx">j</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">vi</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">k1</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">2</span><span class="p">)).</span><span class="nx">map</span><span class="p">(</span><span class="nx">x</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">x</span><span class="p">.</span><span class="nx">map</span><span class="p">(</span><span class="nx">y</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">y</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">dt</span><span class="p">));</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">k3</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">dR</span><span class="p">(</span><span class="nx">r</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">ri</span><span class="p">,</span><span class="w"> </span><span class="nx">j</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">ri</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">k2</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">2</span><span class="p">),</span><span class="w"> </span><span class="nx">v</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">vi</span><span class="p">,</span><span class="w"> </span><span class="nx">j</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">vi</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">k2</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">2</span><span class="p">)).</span><span class="nx">map</span><span class="p">(</span><span class="nx">x</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">x</span><span class="p">.</span><span class="nx">map</span><span class="p">(</span><span class="nx">y</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">y</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">dt</span><span class="p">));</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">k4</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">dR</span><span class="p">(</span><span class="nx">r</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">ri</span><span class="p">,</span><span class="w"> </span><span class="nx">j</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">ri</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">k3</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">j</span><span class="p">]),</span><span class="w"> </span><span class="nx">v</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">vi</span><span class="p">,</span><span class="w"> </span><span class="nx">j</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">vi</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">k3</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">j</span><span class="p">])).</span><span class="nx">map</span><span class="p">(</span><span class="nx">x</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">x</span><span class="p">.</span><span class="nx">map</span><span class="p">(</span><span class="nx">y</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">y</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">dt</span><span class="p">));</span> +<span class="w"> </span><span class="nx">r</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">r</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">ri</span><span class="p">,</span><span class="w"> </span><span class="nx">j</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">ri</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="p">(</span><span class="nx">k1</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">k2</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">k3</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">k4</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">j</span><span class="p">])</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">6</span><span class="p">);</span> +<span class="w"> </span><span class="nx">v</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">v</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">vi</span><span class="p">,</span><span class="w"> </span><span class="nx">j</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">vi</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="p">(</span><span class="nx">k1</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">k2</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">k3</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">j</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">k4</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">j</span><span class="p">])</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">6</span><span class="p">);</span> +<span class="w"> </span><span class="nx">x4Plot</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">r</span><span class="p">[</span><span class="mf">0</span><span class="p">];</span> +<span class="w"> </span><span class="nx">y4Plot</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">r</span><span class="p">[</span><span class="mf">1</span><span class="p">];</span> +<span class="p">}</span> + +<span class="c1">// make data for plot</span> +<span class="kd">var</span><span class="w"> </span><span class="nx">sun</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="mf">0</span><span class="p">,</span><span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="mf">0</span><span class="w"> </span><span class="p">};</span> +<span class="kd">const</span><span class="w"> </span><span class="nx">earth</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="nx">x4Plot</span><span class="p">.</span><span class="nx">map</span><span class="p">(</span><span class="nx">x</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">x</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nx">AU</span><span class="p">),</span><span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="nx">y4Plot</span><span class="p">.</span><span class="nx">map</span><span class="p">(</span><span class="nx">y</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">y</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nx">AU</span><span class="p">)</span><span class="w"> </span><span class="p">};</span> +<span class="kd">const</span><span class="w"> </span><span class="nx">circle</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="nb">Array</span><span class="p">.</span><span class="kr">from</span><span class="p">({</span><span class="w"> </span><span class="nx">length</span><span class="o">:</span><span class="w"> </span><span class="mf">1001</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="p">(</span><span class="nx">_</span><span class="p">,</span><span class="w"> </span><span class="nx">i</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">cos</span><span class="p">(</span><span class="nx">i</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">100</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">PI</span><span class="p">)),</span><span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="nb">Array</span><span class="p">.</span><span class="kr">from</span><span class="p">({</span><span class="w"> </span><span class="nx">length</span><span class="o">:</span><span class="w"> </span><span class="mf">1001</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="p">(</span><span class="nx">_</span><span class="p">,</span><span class="w"> </span><span class="nx">i</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sin</span><span class="p">(</span><span class="nx">i</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">100</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">PI</span><span class="p">))</span><span class="w"> </span><span class="p">};</span> </code></pre> </div> @@ -150,76 +150,77 @@ Next, the function dR takes the position r and velocity v of Earth as input and <h3>Plotting the orbit</h3> -<p>Now that we have the data for the Sun's position, Earth's orbit, and the reference circle, we can plot them using Plotly.js. - <div class="codehilite"> - <pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="nx">traceSun</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="nx">sun</span><span class="p">.</span><span class="nx">x</span><span class="p">],</span><span class="w"></span> - <span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="nx">sun</span><span class="p">.</span><span class="nx">y</span><span class="p">],</span><span class="w"></span> - <span class="w"> </span><span class="nx">mode</span><span class="o">:</span><span class="w"> </span><span class="s2">"markers"</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">marker</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">symbol</span><span class="o">:</span><span class="w"> </span><span class="s2">"star"</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">size</span><span class="o">:</span><span class="w"> </span><span class="mf">10</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">color</span><span class="o">:</span><span class="w"> </span><span class="s2">"gold"</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="w"> </span><span class="nx">name</span><span class="o">:</span><span class="w"> </span><span class="s2">"Sun"</span><span class="p">,</span><span class="w"></span> - <span class="p">};</span><span class="w"></span> - <br /> - <span class="kd">const</span><span class="w"> </span><span class="nx">traceEarth</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="nx">earth</span><span class="p">.</span><span class="nx">x</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="nx">earth</span><span class="p">.</span><span class="nx">y</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">mode</span><span class="o">:</span><span class="w"> </span><span class="s2">"lines"</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">line</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">color</span><span class="o">:</span><span class="w"> </span><span class="s2">"white"</span><span class="w"></span> - <span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="w"> </span><span class="nx">name</span><span class="o">:</span><span class="w"> </span><span class="s2">"Earth"</span><span class="p">,</span><span class="w"></span> - <span class="p">};</span><span class="w"></span> - <br /> - <span class="kd">const</span><span class="w"> </span><span class="nx">traceOrbit</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="nx">circle</span><span class="p">.</span><span class="nx">x</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="nx">circle</span><span class="p">.</span><span class="nx">y</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">mode</span><span class="o">:</span><span class="w"> </span><span class="s2">"lines"</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">line</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">color</span><span class="o">:</span><span class="w"> </span><span class="s2">"crimson"</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">dash</span><span class="o">:</span><span class="w"> </span><span class="s2">"dash"</span><span class="w"></span> - <span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="w"> </span><span class="nx">name</span><span class="o">:</span><span class="w"> </span><span class="s2">"1 AU Circle"</span><span class="p">,</span><span class="w"></span> - <span class="p">};</span><span class="w"></span> - <br /> - <span class="kd">const</span><span class="w"> </span><span class="nx">earthSunLayout</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">title</span><span class="o">:</span><span class="w"> </span><span class="s2">"Earth-Sun Orbit"</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">xaxis</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">title</span><span class="o">:</span><span class="w"> </span><span class="s2">"x [AU]"</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">range</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="mf">1.1</span><span class="p">,</span><span class="mf">1.1</span><span class="p">],</span><span class="w"></span> - <span class="w"> </span><span class="nx">showgrid</span><span class="o">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">gridcolor</span><span class="o">:</span><span class="w"> </span><span class="s2">"rgba(255,255,255,0.5)"</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">gridwidth</span><span class="o">:</span><span class="w"> </span><span class="mf">1</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">zeroline</span><span class="o">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">tickmode</span><span class="o">:</span><span class="w"> </span><span class="s2">"auto"</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">nticks</span><span class="o">:</span><span class="w"> </span><span class="mf">5</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="w"> </span><span class="nx">yaxis</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">title</span><span class="o">:</span><span class="w"> </span><span class="s2">"y [AU]"</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">range</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="mf">1.1</span><span class="p">,</span><span class="mf">1.1</span><span class="p">],</span><span class="w"></span> - <span class="w"> </span><span class="nx">showgrid</span><span class="o">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">gridcolor</span><span class="o">:</span><span class="w"> </span><span class="s2">"rgba(255,255,255,0.5)"</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">gridwidth</span><span class="o">:</span><span class="w"> </span><span class="mf">1</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">zeroline</span><span class="o">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">tickmode</span><span class="o">:</span><span class="w"> </span><span class="s2">"auto"</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">nticks</span><span class="o">:</span><span class="w"> </span><span class="mf">5</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="w"> </span><span class="nx">margin</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">l</span><span class="o">:</span><span class="w"> </span><span class="mf">50</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">r</span><span class="o">:</span><span class="w"> </span><span class="mf">50</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">b</span><span class="o">:</span><span class="w"> </span><span class="mf">50</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">t</span><span class="o">:</span><span class="w"> </span><span class="mf">50</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">pad</span><span class="o">:</span><span class="w"> </span><span class="mf">4</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="w"> </span><span class="nx">paper<em>bgcolor</span><span class="o">:</span><span class="w"> </span><span class="s2">"black"</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">plot</em>bgcolor</span><span class="o">:</span><span class="w"> </span><span class="s2">"black"</span><span class="p">,</span><span class="w"></span> - <span class="p">};</span><span class="w"></span> - <span class="nx">Plotly</span><span class="p">.</span><span class="nx">newPlot</span><span class="p">(</span><span class="s2">"plot"</span><span class="p">,[</span><span class="nx">traceSun</span><span class="p">,</span><span class="nx">traceEarth</span><span class="p">,</span><span class="nx">traceOrbit</span><span class="p">],</span><span class="w"> </span><span class="nx">earthSunLayout</span><span class="p">);</span><span class="w"></span> - </code></pre> - </div></p> +<p>Now that we have the data for the Sun's position, Earth's orbit, and the reference circle, we can plot them using Plotly.js.</p> + +<div class="codehilite"> +<pre><span></span><code><span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">traceSun</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="nx">sun</span><span class="p">.</span><span class="nx">x</span><span class="p">],</span> +<span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="nx">sun</span><span class="p">.</span><span class="nx">y</span><span class="p">],</span> +<span class="w"> </span><span class="nx">mode</span><span class="o">:</span><span class="w"> </span><span class="s2">"markers"</span><span class="p">,</span> +<span class="w"> </span><span class="nx">marker</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">symbol</span><span class="o">:</span><span class="w"> </span><span class="s2">"star"</span><span class="p">,</span> +<span class="w"> </span><span class="nx">size</span><span class="o">:</span><span class="w"> </span><span class="mf">10</span><span class="p">,</span> +<span class="w"> </span><span class="nx">color</span><span class="o">:</span><span class="w"> </span><span class="s2">"gold"</span><span class="p">,</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="nx">name</span><span class="o">:</span><span class="w"> </span><span class="s2">"Sun"</span><span class="p">,</span> +<span class="w"> </span><span class="p">};</span> + +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">traceEarth</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="nx">earth</span><span class="p">.</span><span class="nx">x</span><span class="p">,</span> +<span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="nx">earth</span><span class="p">.</span><span class="nx">y</span><span class="p">,</span> +<span class="w"> </span><span class="nx">mode</span><span class="o">:</span><span class="w"> </span><span class="s2">"lines"</span><span class="p">,</span> +<span class="w"> </span><span class="nx">line</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">color</span><span class="o">:</span><span class="w"> </span><span class="s2">"white"</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="nx">name</span><span class="o">:</span><span class="w"> </span><span class="s2">"Earth"</span><span class="p">,</span> +<span class="w"> </span><span class="p">};</span> + +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">traceOrbit</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="nx">circle</span><span class="p">.</span><span class="nx">x</span><span class="p">,</span> +<span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="nx">circle</span><span class="p">.</span><span class="nx">y</span><span class="p">,</span> +<span class="w"> </span><span class="nx">mode</span><span class="o">:</span><span class="w"> </span><span class="s2">"lines"</span><span class="p">,</span> +<span class="w"> </span><span class="nx">line</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">color</span><span class="o">:</span><span class="w"> </span><span class="s2">"crimson"</span><span class="p">,</span> +<span class="w"> </span><span class="nx">dash</span><span class="o">:</span><span class="w"> </span><span class="s2">"dash"</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="nx">name</span><span class="o">:</span><span class="w"> </span><span class="s2">"1 AU Circle"</span><span class="p">,</span> +<span class="w"> </span><span class="p">};</span> + +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">earthSunLayout</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">title</span><span class="o">:</span><span class="w"> </span><span class="s2">"Earth-Sun Orbit"</span><span class="p">,</span> +<span class="w"> </span><span class="nx">xaxis</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">title</span><span class="o">:</span><span class="w"> </span><span class="s2">"x [AU]"</span><span class="p">,</span> +<span class="w"> </span><span class="nx">range</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="mf">1.1</span><span class="p">,</span><span class="mf">1.1</span><span class="p">],</span> +<span class="w"> </span><span class="nx">showgrid</span><span class="o">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span> +<span class="w"> </span><span class="nx">gridcolor</span><span class="o">:</span><span class="w"> </span><span class="s2">"rgba(255,255,255,0.5)"</span><span class="p">,</span> +<span class="w"> </span><span class="nx">gridwidth</span><span class="o">:</span><span class="w"> </span><span class="mf">1</span><span class="p">,</span> +<span class="w"> </span><span class="nx">zeroline</span><span class="o">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span> +<span class="w"> </span><span class="nx">tickmode</span><span class="o">:</span><span class="w"> </span><span class="s2">"auto"</span><span class="p">,</span> +<span class="w"> </span><span class="nx">nticks</span><span class="o">:</span><span class="w"> </span><span class="mf">5</span><span class="p">,</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="nx">yaxis</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">title</span><span class="o">:</span><span class="w"> </span><span class="s2">"y [AU]"</span><span class="p">,</span> +<span class="w"> </span><span class="nx">range</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="mf">1.1</span><span class="p">,</span><span class="mf">1.1</span><span class="p">],</span> +<span class="w"> </span><span class="nx">showgrid</span><span class="o">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span> +<span class="w"> </span><span class="nx">gridcolor</span><span class="o">:</span><span class="w"> </span><span class="s2">"rgba(255,255,255,0.5)"</span><span class="p">,</span> +<span class="w"> </span><span class="nx">gridwidth</span><span class="o">:</span><span class="w"> </span><span class="mf">1</span><span class="p">,</span> +<span class="w"> </span><span class="nx">zeroline</span><span class="o">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span> +<span class="w"> </span><span class="nx">tickmode</span><span class="o">:</span><span class="w"> </span><span class="s2">"auto"</span><span class="p">,</span> +<span class="w"> </span><span class="nx">nticks</span><span class="o">:</span><span class="w"> </span><span class="mf">5</span><span class="p">,</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="nx">margin</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">l</span><span class="o">:</span><span class="w"> </span><span class="mf">50</span><span class="p">,</span> +<span class="w"> </span><span class="nx">r</span><span class="o">:</span><span class="w"> </span><span class="mf">50</span><span class="p">,</span> +<span class="w"> </span><span class="nx">b</span><span class="o">:</span><span class="w"> </span><span class="mf">50</span><span class="p">,</span> +<span class="w"> </span><span class="nx">t</span><span class="o">:</span><span class="w"> </span><span class="mf">50</span><span class="p">,</span> +<span class="w"> </span><span class="nx">pad</span><span class="o">:</span><span class="w"> </span><span class="mf">4</span><span class="p">,</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="nx">paper_bgcolor</span><span class="o">:</span><span class="w"> </span><span class="s2">"black"</span><span class="p">,</span> +<span class="w"> </span><span class="nx">plot_bgcolor</span><span class="o">:</span><span class="w"> </span><span class="s2">"black"</span><span class="p">,</span> +<span class="w"> </span><span class="p">};</span> +<span class="w"> </span><span class="nx">Plotly</span><span class="p">.</span><span class="nx">newPlot</span><span class="p">(</span><span class="s2">"plot"</span><span class="p">,[</span><span class="nx">traceSun</span><span class="p">,</span><span class="nx">traceEarth</span><span class="p">,</span><span class="nx">traceOrbit</span><span class="p">],</span><span class="w"> </span><span class="nx">earthSunLayout</span><span class="p">);</span> +</code></pre> +</div> <h2>Figure of 8 orbit</h2> @@ -240,78 +241,78 @@ Next, the function dR takes the position r and velocity v of Earth as input and <p>The code for this simulation is very similar to the Earth-Sun orbit simulation, except that we now have three bodies instead of two. We also use a different set of initial conditions to generate the figure of 8 orbit.</p> <div class="codehilite"> -<pre><span></span><code><span class="kd">function</span><span class="w"> </span><span class="nx">deltaR</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">0</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">y</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">1</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">vx</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">2</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">vy</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">3</span><span class="p">];</span><span class="w"></span> - -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">delta</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">clone</span><span class="p">(</span><span class="nx">coords</span><span class="p">);</span><span class="w"></span> - -<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kd">let</span><span class="w"> </span><span class="nx">n</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="nx">n</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">;</span><span class="w"> </span><span class="nx">n</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">xn</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">x</span><span class="p">[</span><span class="nx">n</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">yn</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">y</span><span class="p">[</span><span class="nx">n</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">deltaVx</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0.0</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">deltaVy</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0.0</span><span class="p">;</span><span class="w"></span> - -<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kd">let</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">i</span><span class="w"> </span><span class="o">!==</span><span class="w"> </span><span class="nx">n</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">sep</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sqrt</span><span class="p">(</span><span class="nb">Math</span><span class="p">.</span><span class="nx">pow</span><span class="p">(</span><span class="nx">xn</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">x</span><span class="p">[</span><span class="nx">i</span><span class="p">],</span><span class="w"> </span><span class="mf">2</span><span class="p">)</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">pow</span><span class="p">(</span><span class="nx">yn</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">y</span><span class="p">[</span><span class="nx">i</span><span class="p">],</span><span class="w"> </span><span class="mf">2</span><span class="p">));</span><span class="w"> </span><span class="c1">// Euclidean distance</span><span class="w"></span> -<span class="w"> </span><span class="nx">deltaVx</span><span class="w"> </span><span class="o">-=</span><span class="w"> </span><span class="nx">G</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="p">(</span><span class="nx">xn</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">x</span><span class="p">[</span><span class="nx">i</span><span class="p">])</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">pow</span><span class="p">(</span><span class="nx">sep</span><span class="p">,</span><span class="w"> </span><span class="mf">3</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="nx">deltaVy</span><span class="w"> </span><span class="o">-=</span><span class="w"> </span><span class="nx">G</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="p">(</span><span class="nx">yn</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">y</span><span class="p">[</span><span class="nx">i</span><span class="p">])</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">pow</span><span class="p">(</span><span class="nx">sep</span><span class="p">,</span><span class="w"> </span><span class="mf">3</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> - -<span class="w"> </span><span class="nx">delta</span><span class="p">[</span><span class="mf">2</span><span class="p">][</span><span class="nx">n</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">deltaVx</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="nx">delta</span><span class="p">[</span><span class="mf">3</span><span class="p">][</span><span class="nx">n</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">deltaVy</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> - -<span class="w"> </span><span class="nx">delta</span><span class="p">[</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">vx</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="nx">delta</span><span class="p">[</span><span class="mf">1</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">vy</span><span class="p">;</span><span class="w"></span> - -<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="nx">delta</span><span class="p">;</span><span class="w"></span> -<span class="p">}</span><span class="w"></span> - -<span class="kd">function</span><span class="w"> </span><span class="nx">step</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">3</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">6.67408313131313e-11</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">k1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaR</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">));</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">k2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaR</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">k1</span><span class="p">,</span><span class="w"> </span><span class="mf">0.5</span><span class="p">)),</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">));</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">k3</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaR</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">k2</span><span class="p">,</span><span class="w"> </span><span class="mf">0.5</span><span class="p">)),</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">));</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">k4</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaR</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">k3</span><span class="p">),</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">));</span><span class="w"></span> - -<span class="w"> </span><span class="nx">coords</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">k1</span><span class="p">,</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="mf">2.0</span><span class="p">,</span><span class="w"> </span><span class="nx">k2</span><span class="p">),</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="mf">2.0</span><span class="p">,</span><span class="w"> </span><span class="nx">k3</span><span class="p">),</span><span class="w"> </span><span class="nx">k4</span><span class="p">),</span><span class="w"> </span><span class="mf">1</span><span class="o">/</span><span class="mf">6</span><span class="p">));</span><span class="w"></span> - -<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="nx">coords</span><span class="p">;</span><span class="w"></span> -<span class="p">}</span><span class="w"></span> - -<span class="w"> </span><span class="c1">// Initial conditions setup</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">M</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="mf">1</span><span class="p">,</span><span class="w"> </span><span class="mf">1</span><span class="p">,</span><span class="w"> </span><span class="mf">1</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="mf">0.97000436</span><span class="p">,</span><span class="w"> </span><span class="mf">0.0</span><span class="p">,</span><span class="w"> </span><span class="mf">0.97000436</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">y</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="mf">0.24208753</span><span class="p">,</span><span class="w"> </span><span class="mf">0.0</span><span class="p">,</span><span class="w"> </span><span class="o">-</span><span class="mf">0.24208753</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">vx</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="mf">0.4662036850</span><span class="p">,</span><span class="w"> </span><span class="o">-</span><span class="mf">0.933240737</span><span class="p">,</span><span class="w"> </span><span class="mf">0.4662036850</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">vy</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="mf">0.4323657300</span><span class="p">,</span><span class="w"> </span><span class="o">-</span><span class="mf">0.86473146</span><span class="p">,</span><span class="w"> </span><span class="mf">0.4323657300</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">Ei</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">-</span><span class="mf">1</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sqrt</span><span class="p">(</span><span class="nb">Math</span><span class="p">.</span><span class="nx">pow</span><span class="p">(</span><span class="mf">2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">0.97000436</span><span class="p">,</span><span class="w"> </span><span class="mf">2</span><span class="p">)</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">pow</span><span class="p">(</span><span class="mf">2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">0.24208753</span><span class="p">,</span><span class="w"> </span><span class="mf">2</span><span class="p">))</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sqrt</span><span class="p">(</span><span class="nb">Math</span><span class="p">.</span><span class="nx">pow</span><span class="p">(</span><span class="mf">0.97000436</span><span class="p">,</span><span class="w"> </span><span class="mf">2</span><span class="p">)</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">pow</span><span class="p">(</span><span class="mf">0.24208753</span><span class="p">,</span><span class="w"> </span><span class="mf">2</span><span class="p">))</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mf">0.5</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">sum</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">dotPow</span><span class="p">(</span><span class="nx">vx</span><span class="p">,</span><span class="w"> </span><span class="mf">2</span><span class="p">),</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">dotPow</span><span class="p">(</span><span class="nx">vy</span><span class="p">,</span><span class="w"> </span><span class="mf">2</span><span class="p">))));</span><span class="w"></span> - -<span class="w"> </span><span class="kd">function</span><span class="w"> </span><span class="nx">linspace</span><span class="p">(</span><span class="nx">start</span><span class="p">,</span><span class="w"> </span><span class="nx">stop</span><span class="p">,</span><span class="w"> </span><span class="nx">num</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">step</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="nx">stop</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">start</span><span class="p">)</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="p">(</span><span class="nx">num</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mf">1</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="nb">Array</span><span class="p">.</span><span class="kr">from</span><span class="p">({</span><span class="nx">length</span><span class="o">:</span><span class="w"> </span><span class="nx">num</span><span class="p">},</span><span class="w"> </span><span class="p">(</span><span class="nx">_</span><span class="p">,</span><span class="w"> </span><span class="nx">i</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">start</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="p">(</span><span class="nx">step</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">i</span><span class="p">));</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> - -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">coords</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nx">x</span><span class="p">,</span><span class="w"> </span><span class="nx">y</span><span class="p">,</span><span class="w"> </span><span class="nx">vx</span><span class="p">,</span><span class="w"> </span><span class="nx">vy</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">time</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">linspace</span><span class="p">(</span><span class="mf">0</span><span class="p">,</span><span class="w"> </span><span class="mf">6.3259</span><span class="p">,</span><span class="w"> </span><span class="mf">1001</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">deltaT</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">time</span><span class="p">[</span><span class="mf">1</span><span class="p">]</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">time</span><span class="p">[</span><span class="mf">0</span><span class="p">];</span><span class="w"></span> - -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">X</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">zeros</span><span class="p">(</span><span class="mf">3</span><span class="p">,</span><span class="w"> </span><span class="nx">time</span><span class="p">.</span><span class="nx">length</span><span class="p">).</span><span class="nx">toArray</span><span class="p">();</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">Y</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">zeros</span><span class="p">(</span><span class="mf">3</span><span class="p">,</span><span class="w"> </span><span class="nx">time</span><span class="p">.</span><span class="nx">length</span><span class="p">).</span><span class="nx">toArray</span><span class="p">();</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">VX</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">zeros</span><span class="p">(</span><span class="mf">3</span><span class="p">,</span><span class="w"> </span><span class="nx">time</span><span class="p">.</span><span class="nx">length</span><span class="p">).</span><span class="nx">toArray</span><span class="p">();</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">VY</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">zeros</span><span class="p">(</span><span class="mf">3</span><span class="p">,</span><span class="w"> </span><span class="nx">time</span><span class="p">.</span><span class="nx">length</span><span class="p">).</span><span class="nx">toArray</span><span class="p">();</span><span class="w"></span> - -<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kd">let</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">time</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="nx">coords</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">step</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">M</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="mf">3</span><span class="p">,</span><span class="w"> </span><span class="mf">1</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="nx">X</span><span class="p">.</span><span class="nx">forEach</span><span class="p">((</span><span class="nx">_</span><span class="p">,</span><span class="w"> </span><span class="nx">idx</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">X</span><span class="p">[</span><span class="nx">idx</span><span class="p">][</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">idx</span><span class="p">]);</span><span class="w"></span> -<span class="w"> </span><span class="nx">Y</span><span class="p">.</span><span class="nx">forEach</span><span class="p">((</span><span class="nx">_</span><span class="p">,</span><span class="w"> </span><span class="nx">idx</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">Y</span><span class="p">[</span><span class="nx">idx</span><span class="p">][</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">idx</span><span class="p">]);</span><span class="w"></span> -<span class="w"> </span><span class="nx">VX</span><span class="p">.</span><span class="nx">forEach</span><span class="p">((</span><span class="nx">_</span><span class="p">,</span><span class="w"> </span><span class="nx">idx</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">VX</span><span class="p">[</span><span class="nx">idx</span><span class="p">][</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">2</span><span class="p">][</span><span class="nx">idx</span><span class="p">]);</span><span class="w"></span> -<span class="w"> </span><span class="nx">VY</span><span class="p">.</span><span class="nx">forEach</span><span class="p">((</span><span class="nx">_</span><span class="p">,</span><span class="w"> </span><span class="nx">idx</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">VY</span><span class="p">[</span><span class="nx">idx</span><span class="p">][</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">3</span><span class="p">][</span><span class="nx">idx</span><span class="p">]);</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> +<pre><span></span><code><span class="kd">function</span><span class="w"> </span><span class="nx">deltaR</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">0</span><span class="p">];</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">y</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">1</span><span class="p">];</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">vx</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">2</span><span class="p">];</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">vy</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">3</span><span class="p">];</span> + +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">delta</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">clone</span><span class="p">(</span><span class="nx">coords</span><span class="p">);</span> + +<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kd">let</span><span class="w"> </span><span class="nx">n</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="nx">n</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">;</span><span class="w"> </span><span class="nx">n</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">xn</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">x</span><span class="p">[</span><span class="nx">n</span><span class="p">];</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">yn</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">y</span><span class="p">[</span><span class="nx">n</span><span class="p">];</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">deltaVx</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0.0</span><span class="p">;</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">deltaVy</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0.0</span><span class="p">;</span> + +<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kd">let</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">i</span><span class="w"> </span><span class="o">!==</span><span class="w"> </span><span class="nx">n</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">sep</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sqrt</span><span class="p">(</span><span class="nb">Math</span><span class="p">.</span><span class="nx">pow</span><span class="p">(</span><span class="nx">xn</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">x</span><span class="p">[</span><span class="nx">i</span><span class="p">],</span><span class="w"> </span><span class="mf">2</span><span class="p">)</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">pow</span><span class="p">(</span><span class="nx">yn</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">y</span><span class="p">[</span><span class="nx">i</span><span class="p">],</span><span class="w"> </span><span class="mf">2</span><span class="p">));</span><span class="w"> </span><span class="c1">// Euclidean distance</span> +<span class="w"> </span><span class="nx">deltaVx</span><span class="w"> </span><span class="o">-=</span><span class="w"> </span><span class="nx">G</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="p">(</span><span class="nx">xn</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">x</span><span class="p">[</span><span class="nx">i</span><span class="p">])</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">pow</span><span class="p">(</span><span class="nx">sep</span><span class="p">,</span><span class="w"> </span><span class="mf">3</span><span class="p">);</span> +<span class="w"> </span><span class="nx">deltaVy</span><span class="w"> </span><span class="o">-=</span><span class="w"> </span><span class="nx">G</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="p">(</span><span class="nx">yn</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">y</span><span class="p">[</span><span class="nx">i</span><span class="p">])</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">pow</span><span class="p">(</span><span class="nx">sep</span><span class="p">,</span><span class="w"> </span><span class="mf">3</span><span class="p">);</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="p">}</span> + +<span class="w"> </span><span class="nx">delta</span><span class="p">[</span><span class="mf">2</span><span class="p">][</span><span class="nx">n</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">deltaVx</span><span class="p">;</span> +<span class="w"> </span><span class="nx">delta</span><span class="p">[</span><span class="mf">3</span><span class="p">][</span><span class="nx">n</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">deltaVy</span><span class="p">;</span> +<span class="w"> </span><span class="p">}</span> + +<span class="w"> </span><span class="nx">delta</span><span class="p">[</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">vx</span><span class="p">;</span> +<span class="w"> </span><span class="nx">delta</span><span class="p">[</span><span class="mf">1</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">vy</span><span class="p">;</span> + +<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="nx">delta</span><span class="p">;</span> +<span class="p">}</span> + +<span class="kd">function</span><span class="w"> </span><span class="nx">step</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">3</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">6.67408313131313e-11</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">k1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaR</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">));</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">k2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaR</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">k1</span><span class="p">,</span><span class="w"> </span><span class="mf">0.5</span><span class="p">)),</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">));</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">k3</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaR</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">k2</span><span class="p">,</span><span class="w"> </span><span class="mf">0.5</span><span class="p">)),</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">));</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">k4</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaR</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">k3</span><span class="p">),</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">));</span> + +<span class="w"> </span><span class="nx">coords</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">k1</span><span class="p">,</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="mf">2.0</span><span class="p">,</span><span class="w"> </span><span class="nx">k2</span><span class="p">),</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="mf">2.0</span><span class="p">,</span><span class="w"> </span><span class="nx">k3</span><span class="p">),</span><span class="w"> </span><span class="nx">k4</span><span class="p">),</span><span class="w"> </span><span class="mf">1</span><span class="o">/</span><span class="mf">6</span><span class="p">));</span> + +<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="nx">coords</span><span class="p">;</span> +<span class="p">}</span> + +<span class="w"> </span><span class="c1">// Initial conditions setup</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">M</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="mf">1</span><span class="p">,</span><span class="w"> </span><span class="mf">1</span><span class="p">,</span><span class="w"> </span><span class="mf">1</span><span class="p">];</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="mf">0.97000436</span><span class="p">,</span><span class="w"> </span><span class="mf">0.0</span><span class="p">,</span><span class="w"> </span><span class="mf">0.97000436</span><span class="p">];</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">y</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="mf">0.24208753</span><span class="p">,</span><span class="w"> </span><span class="mf">0.0</span><span class="p">,</span><span class="w"> </span><span class="o">-</span><span class="mf">0.24208753</span><span class="p">];</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">vx</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="mf">0.4662036850</span><span class="p">,</span><span class="w"> </span><span class="o">-</span><span class="mf">0.933240737</span><span class="p">,</span><span class="w"> </span><span class="mf">0.4662036850</span><span class="p">];</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">vy</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="mf">0.4323657300</span><span class="p">,</span><span class="w"> </span><span class="o">-</span><span class="mf">0.86473146</span><span class="p">,</span><span class="w"> </span><span class="mf">0.4323657300</span><span class="p">];</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">Ei</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">-</span><span class="mf">1</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sqrt</span><span class="p">(</span><span class="nb">Math</span><span class="p">.</span><span class="nx">pow</span><span class="p">(</span><span class="mf">2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">0.97000436</span><span class="p">,</span><span class="w"> </span><span class="mf">2</span><span class="p">)</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">pow</span><span class="p">(</span><span class="mf">2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">0.24208753</span><span class="p">,</span><span class="w"> </span><span class="mf">2</span><span class="p">))</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sqrt</span><span class="p">(</span><span class="nb">Math</span><span class="p">.</span><span class="nx">pow</span><span class="p">(</span><span class="mf">0.97000436</span><span class="p">,</span><span class="w"> </span><span class="mf">2</span><span class="p">)</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">pow</span><span class="p">(</span><span class="mf">0.24208753</span><span class="p">,</span><span class="w"> </span><span class="mf">2</span><span class="p">))</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mf">0.5</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">sum</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">dotPow</span><span class="p">(</span><span class="nx">vx</span><span class="p">,</span><span class="w"> </span><span class="mf">2</span><span class="p">),</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">dotPow</span><span class="p">(</span><span class="nx">vy</span><span class="p">,</span><span class="w"> </span><span class="mf">2</span><span class="p">))));</span> + +<span class="w"> </span><span class="kd">function</span><span class="w"> </span><span class="nx">linspace</span><span class="p">(</span><span class="nx">start</span><span class="p">,</span><span class="w"> </span><span class="nx">stop</span><span class="p">,</span><span class="w"> </span><span class="nx">num</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">step</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="nx">stop</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">start</span><span class="p">)</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="p">(</span><span class="nx">num</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mf">1</span><span class="p">);</span> +<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="nb">Array</span><span class="p">.</span><span class="kr">from</span><span class="p">({</span><span class="nx">length</span><span class="o">:</span><span class="w"> </span><span class="nx">num</span><span class="p">},</span><span class="w"> </span><span class="p">(</span><span class="nx">_</span><span class="p">,</span><span class="w"> </span><span class="nx">i</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">start</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="p">(</span><span class="nx">step</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">i</span><span class="p">));</span> +<span class="w"> </span><span class="p">}</span> + +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">coords</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nx">x</span><span class="p">,</span><span class="w"> </span><span class="nx">y</span><span class="p">,</span><span class="w"> </span><span class="nx">vx</span><span class="p">,</span><span class="w"> </span><span class="nx">vy</span><span class="p">];</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">time</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">linspace</span><span class="p">(</span><span class="mf">0</span><span class="p">,</span><span class="w"> </span><span class="mf">6.3259</span><span class="p">,</span><span class="w"> </span><span class="mf">1001</span><span class="p">);</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">deltaT</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">time</span><span class="p">[</span><span class="mf">1</span><span class="p">]</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">time</span><span class="p">[</span><span class="mf">0</span><span class="p">];</span> + +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">X</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">zeros</span><span class="p">(</span><span class="mf">3</span><span class="p">,</span><span class="w"> </span><span class="nx">time</span><span class="p">.</span><span class="nx">length</span><span class="p">).</span><span class="nx">toArray</span><span class="p">();</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">Y</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">zeros</span><span class="p">(</span><span class="mf">3</span><span class="p">,</span><span class="w"> </span><span class="nx">time</span><span class="p">.</span><span class="nx">length</span><span class="p">).</span><span class="nx">toArray</span><span class="p">();</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">VX</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">zeros</span><span class="p">(</span><span class="mf">3</span><span class="p">,</span><span class="w"> </span><span class="nx">time</span><span class="p">.</span><span class="nx">length</span><span class="p">).</span><span class="nx">toArray</span><span class="p">();</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">VY</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">zeros</span><span class="p">(</span><span class="mf">3</span><span class="p">,</span><span class="w"> </span><span class="nx">time</span><span class="p">.</span><span class="nx">length</span><span class="p">).</span><span class="nx">toArray</span><span class="p">();</span> + +<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kd">let</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">time</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">coords</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">step</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">M</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="mf">3</span><span class="p">,</span><span class="w"> </span><span class="mf">1</span><span class="p">);</span> +<span class="w"> </span><span class="nx">X</span><span class="p">.</span><span class="nx">forEach</span><span class="p">((</span><span class="nx">_</span><span class="p">,</span><span class="w"> </span><span class="nx">idx</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">X</span><span class="p">[</span><span class="nx">idx</span><span class="p">][</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">idx</span><span class="p">]);</span> +<span class="w"> </span><span class="nx">Y</span><span class="p">.</span><span class="nx">forEach</span><span class="p">((</span><span class="nx">_</span><span class="p">,</span><span class="w"> </span><span class="nx">idx</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">Y</span><span class="p">[</span><span class="nx">idx</span><span class="p">][</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">idx</span><span class="p">]);</span> +<span class="w"> </span><span class="nx">VX</span><span class="p">.</span><span class="nx">forEach</span><span class="p">((</span><span class="nx">_</span><span class="p">,</span><span class="w"> </span><span class="nx">idx</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">VX</span><span class="p">[</span><span class="nx">idx</span><span class="p">][</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">2</span><span class="p">][</span><span class="nx">idx</span><span class="p">]);</span> +<span class="w"> </span><span class="nx">VY</span><span class="p">.</span><span class="nx">forEach</span><span class="p">((</span><span class="nx">_</span><span class="p">,</span><span class="w"> </span><span class="nx">idx</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">VY</span><span class="p">[</span><span class="nx">idx</span><span class="p">][</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">3</span><span class="p">][</span><span class="nx">idx</span><span class="p">]);</span> +<span class="w"> </span><span class="p">}</span> </code></pre> </div> @@ -329,365 +330,369 @@ Next, the function dR takes the position r and velocity v of Earth as input and <h3>Animation?</h3> -<p>Now that we have time-series data, we need to animate it. We can use Plotly's animate function, as this does not force a full re-render, saving us some precious GPU and CPU cycles when we are trying to run this in the browser itself - <div class="codehilite"> - <pre><span></span><code><span class="kd">function</span><span class="w"> </span><span class="nx">plotClassicFunc</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">tailLength</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">1</span><span class="p">;</span><span class="w"></span> - <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">plotIndex</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">tailLength</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">tailLength</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"></span> - <span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">plotIndex</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="nx">time</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">plotIndex</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"></span> - <span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">tailLength</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">plotIndex</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">tailLength</span><span class="p">;</span><span class="w"></span> - <span class="w"> </span><span class="p">}</span><span class="w"></span> - <br /> - <span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">currentIndex</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">plotIndex</span><span class="p">;</span><span class="w"></span> - <br /> - <span class="w"> </span><span class="k">try</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">time</span><span class="p">[</span><span class="nx">currentIndex</span><span class="p">].</span><span class="nx">toFixed</span><span class="p">(</span><span class="mf">3</span><span class="p">);</span><span class="w"></span> - <span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">catch</span><span class="w"> </span><span class="p">(</span><span class="nx">e</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">currentIndex</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"></span> - <span class="w"> </span><span class="p">}</span><span class="w"></span> - <br /> - <span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">data</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="w"></span> - <span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="nx">X</span><span class="p">[</span><span class="mf">0</span><span class="p">].</span><span class="nx">slice</span><span class="p">(</span><span class="nx">tailLength</span><span class="p">,</span><span class="w"> </span><span class="nx">currentIndex</span><span class="p">),</span><span class="w"></span> - <span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="nx">Y</span><span class="p">[</span><span class="mf">0</span><span class="p">].</span><span class="nx">slice</span><span class="p">(</span><span class="nx">tailLength</span><span class="p">,</span><span class="w"> </span><span class="nx">currentIndex</span><span class="p">),</span><span class="w"></span> - <span class="w"> </span><span class="nx">mode</span><span class="o">:</span><span class="w"> </span><span class="s1">'lines+markers'</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">marker</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">symbol</span><span class="o">:</span><span class="w"> </span><span class="s1">'star'</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">size</span><span class="o">:</span><span class="w"> </span><span class="mf">8</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">line</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">width</span><span class="o">:</span><span class="w"> </span><span class="mf">0</span><span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="w"> </span><span class="nx">line</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">width</span><span class="o">:</span><span class="w"> </span><span class="mf">2</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="w"> </span><span class="nx">name</span><span class="o">:</span><span class="w"> </span><span class="s1">''</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="nx">X</span><span class="p">[</span><span class="mf">1</span><span class="p">].</span><span class="nx">slice</span><span class="p">(</span><span class="nx">tailLength</span><span class="p">,</span><span class="w"> </span><span class="nx">currentIndex</span><span class="p">),</span><span class="w"></span> - <span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="nx">Y</span><span class="p">[</span><span class="mf">1</span><span class="p">].</span><span class="nx">slice</span><span class="p">(</span><span class="nx">tailLength</span><span class="p">,</span><span class="w"> </span><span class="nx">currentIndex</span><span class="p">),</span><span class="w"></span> - <span class="w"> </span><span class="nx">mode</span><span class="o">:</span><span class="w"> </span><span class="s1">'lines+markers'</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">marker</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">symbol</span><span class="o">:</span><span class="w"> </span><span class="s1">'star'</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">size</span><span class="o">:</span><span class="w"> </span><span class="mf">8</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">line</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">width</span><span class="o">:</span><span class="w"> </span><span class="mf">0</span><span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="w"> </span><span class="nx">line</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">width</span><span class="o">:</span><span class="w"> </span><span class="mf">2</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="w"> </span><span class="nx">name</span><span class="o">:</span><span class="w"> </span><span class="s1">''</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="nx">X</span><span class="p">[</span><span class="mf">2</span><span class="p">].</span><span class="nx">slice</span><span class="p">(</span><span class="nx">tailLength</span><span class="p">,</span><span class="w"> </span><span class="nx">currentIndex</span><span class="p">),</span><span class="w"></span> - <span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="nx">Y</span><span class="p">[</span><span class="mf">2</span><span class="p">].</span><span class="nx">slice</span><span class="p">(</span><span class="nx">tailLength</span><span class="p">,</span><span class="w"> </span><span class="nx">currentIndex</span><span class="p">),</span><span class="w"></span> - <span class="w"> </span><span class="nx">mode</span><span class="o">:</span><span class="w"> </span><span class="s1">'lines+markers'</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">marker</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">symbol</span><span class="o">:</span><span class="w"> </span><span class="s1">'star'</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">size</span><span class="o">:</span><span class="w"> </span><span class="mf">8</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">line</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">width</span><span class="o">:</span><span class="w"> </span><span class="mf">0</span><span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="w"> </span><span class="nx">line</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">width</span><span class="o">:</span><span class="w"> </span><span class="mf">2</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="w"> </span><span class="nx">name</span><span class="o">:</span><span class="w"> </span><span class="s1">''</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="p">];</span><span class="w"></span> - <br /> - <span class="c1">// width: 1000, height: 400</span><span class="w"></span> - <span class="kd">const</span><span class="w"> </span><span class="nx">layout</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">title</span><span class="o">:</span><span class="w"> </span><span class="s1">'∞ Three-Body Problem: t = '</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">time</span><span class="p">[</span><span class="nx">currentIndex</span><span class="p">].</span><span class="nx">toFixed</span><span class="p">(</span><span class="mf">3</span><span class="p">),</span><span class="w"></span> - <span class="w"> </span><span class="nx">xaxis</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">title</span><span class="o">:</span><span class="w"> </span><span class="s1">'x'</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">range</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="mf">1.1</span><span class="p">,</span><span class="mf">1.1</span><span class="p">]</span><span class="w"></span> - <span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="w"> </span><span class="nx">yaxis</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">title</span><span class="o">:</span><span class="w"> </span><span class="s1">'y'</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">scaleanchor</span><span class="o">:</span><span class="w"> </span><span class="s1">'x'</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">scaleratio</span><span class="o">:</span><span class="w"> </span><span class="mf">1</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">range</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="mf">0.5</span><span class="p">,</span><span class="mf">0.5</span><span class="p">]</span><span class="w"></span> - <span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="w"> </span><span class="nx">plot<em>bgcolor</span><span class="o">:</span><span class="w"> </span><span class="s1">'black'</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">paper</em>bgcolor</span><span class="o">:</span><span class="w"> </span><span class="s1">'black'</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">font</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">color</span><span class="o">:</span><span class="w"> </span><span class="s1">'white'</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="p">};</span><span class="w"></span> - <br /> - <span class="k">try</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="nx">Plotly</span><span class="p">.</span><span class="nx">animate</span><span class="p">(</span><span class="s2">"plot"</span><span class="p">,</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">data</span><span class="o">:</span><span class="w"> </span><span class="nx">data</span><span class="p">,</span><span class="w"> </span><span class="nx">layout</span><span class="o">:</span><span class="w"> </span><span class="nx">layout</span><span class="w"></span> - <span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">staticPlot</span><span class="o">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">transition</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">duration</span><span class="o">:</span><span class="w"> </span><span class="mf">0</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="p">},</span><span class="w"></span> - <span class="w"> </span><span class="nx">frame</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">duration</span><span class="o">:</span><span class="w"> </span><span class="mf">0</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="nx">redraw</span><span class="o">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w"></span> - <span class="w"> </span><span class="p">}</span><span class="w"></span> - <span class="w"> </span><span class="p">});</span><span class="w"></span> - <span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">catch</span><span class="w"> </span><span class="p">(</span><span class="nx">err</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">Plotly</span><span class="p">.</span><span class="nx">newPlot</span><span class="p">(</span><span class="s1">'plot'</span><span class="p">,</span><span class="w"> </span><span class="nx">data</span><span class="p">,</span><span class="w"> </span><span class="nx">layout</span><span class="p">);</span><span class="w"></span> - <span class="w"> </span><span class="p">}</span><span class="w"></span> - <br /> - <br /> - <span class="nx">plotIndex</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="nx">delay</span><span class="p">;</span><span class="w"></span> - <span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">plotClassic</span><span class="o">===</span><span class="kc">true</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="k">try</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">requestAnimationFrame</span><span class="p">(</span><span class="nx">plotClassicFunc</span><span class="p">);</span><span class="w"></span> - <span class="w"> </span><span class="p">}</span><span class="w"></span> - <span class="w"> </span><span class="k">catch</span><span class="w"> </span><span class="p">(</span><span class="nx">err</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - <span class="w"> </span><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span><span class="w"></span> - <span class="w"> </span><span class="p">}</span><span class="w"></span> - <span class="p">}</span><span class="w"></span> - <br /> - <span class="p">}</span><span class="w"></span> - </code></pre> - </div></p> +<p>Now that we have time-series data, we need to animate it. We can use Plotly's animate function, as this does not force a full re-render, saving us some precious GPU and CPU cycles when we are trying to run this in the browser itself</p> + +<div class="codehilite"> +<pre><span></span><code><span class="w"> </span><span class="kd">function</span><span class="w"> </span><span class="nx">plotClassicFunc</span><span class="p">()</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">tailLength</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">1</span><span class="p">;</span> +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">plotIndex</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">tailLength</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">tailLength</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span> +<span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">plotIndex</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="nx">time</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">plotIndex</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span> +<span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">tailLength</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">plotIndex</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">tailLength</span><span class="p">;</span> +<span class="w"> </span><span class="p">}</span> + +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">currentIndex</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">plotIndex</span><span class="p">;</span> + +<span class="w"> </span><span class="k">try</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">time</span><span class="p">[</span><span class="nx">currentIndex</span><span class="p">].</span><span class="nx">toFixed</span><span class="p">(</span><span class="mf">3</span><span class="p">);</span> +<span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">catch</span><span class="w"> </span><span class="p">(</span><span class="nx">e</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">currentIndex</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span> +<span class="w"> </span><span class="p">}</span> + +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">data</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span> +<span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="nx">X</span><span class="p">[</span><span class="mf">0</span><span class="p">].</span><span class="nx">slice</span><span class="p">(</span><span class="nx">tailLength</span><span class="p">,</span><span class="w"> </span><span class="nx">currentIndex</span><span class="p">),</span> +<span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="nx">Y</span><span class="p">[</span><span class="mf">0</span><span class="p">].</span><span class="nx">slice</span><span class="p">(</span><span class="nx">tailLength</span><span class="p">,</span><span class="w"> </span><span class="nx">currentIndex</span><span class="p">),</span> +<span class="w"> </span><span class="nx">mode</span><span class="o">:</span><span class="w"> </span><span class="s1">'lines+markers'</span><span class="p">,</span> +<span class="w"> </span><span class="nx">marker</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">symbol</span><span class="o">:</span><span class="w"> </span><span class="s1">'star'</span><span class="p">,</span> +<span class="w"> </span><span class="nx">size</span><span class="o">:</span><span class="w"> </span><span class="mf">8</span><span class="p">,</span> +<span class="w"> </span><span class="nx">line</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">width</span><span class="o">:</span><span class="w"> </span><span class="mf">0</span><span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="nx">line</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">width</span><span class="o">:</span><span class="w"> </span><span class="mf">2</span><span class="p">,</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="nx">name</span><span class="o">:</span><span class="w"> </span><span class="s1">''</span><span class="p">,</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="nx">X</span><span class="p">[</span><span class="mf">1</span><span class="p">].</span><span class="nx">slice</span><span class="p">(</span><span class="nx">tailLength</span><span class="p">,</span><span class="w"> </span><span class="nx">currentIndex</span><span class="p">),</span> +<span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="nx">Y</span><span class="p">[</span><span class="mf">1</span><span class="p">].</span><span class="nx">slice</span><span class="p">(</span><span class="nx">tailLength</span><span class="p">,</span><span class="w"> </span><span class="nx">currentIndex</span><span class="p">),</span> +<span class="w"> </span><span class="nx">mode</span><span class="o">:</span><span class="w"> </span><span class="s1">'lines+markers'</span><span class="p">,</span> +<span class="w"> </span><span class="nx">marker</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">symbol</span><span class="o">:</span><span class="w"> </span><span class="s1">'star'</span><span class="p">,</span> +<span class="w"> </span><span class="nx">size</span><span class="o">:</span><span class="w"> </span><span class="mf">8</span><span class="p">,</span> +<span class="w"> </span><span class="nx">line</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">width</span><span class="o">:</span><span class="w"> </span><span class="mf">0</span><span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="nx">line</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">width</span><span class="o">:</span><span class="w"> </span><span class="mf">2</span><span class="p">,</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="nx">name</span><span class="o">:</span><span class="w"> </span><span class="s1">''</span><span class="p">,</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="nx">X</span><span class="p">[</span><span class="mf">2</span><span class="p">].</span><span class="nx">slice</span><span class="p">(</span><span class="nx">tailLength</span><span class="p">,</span><span class="w"> </span><span class="nx">currentIndex</span><span class="p">),</span> +<span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="nx">Y</span><span class="p">[</span><span class="mf">2</span><span class="p">].</span><span class="nx">slice</span><span class="p">(</span><span class="nx">tailLength</span><span class="p">,</span><span class="w"> </span><span class="nx">currentIndex</span><span class="p">),</span> +<span class="w"> </span><span class="nx">mode</span><span class="o">:</span><span class="w"> </span><span class="s1">'lines+markers'</span><span class="p">,</span> +<span class="w"> </span><span class="nx">marker</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">symbol</span><span class="o">:</span><span class="w"> </span><span class="s1">'star'</span><span class="p">,</span> +<span class="w"> </span><span class="nx">size</span><span class="o">:</span><span class="w"> </span><span class="mf">8</span><span class="p">,</span> +<span class="w"> </span><span class="nx">line</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">width</span><span class="o">:</span><span class="w"> </span><span class="mf">0</span><span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="nx">line</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">width</span><span class="o">:</span><span class="w"> </span><span class="mf">2</span><span class="p">,</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="nx">name</span><span class="o">:</span><span class="w"> </span><span class="s1">''</span><span class="p">,</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="p">];</span> + +<span class="w"> </span><span class="c1">// width: 1000, height: 400</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">layout</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">title</span><span class="o">:</span><span class="w"> </span><span class="s1">'∞ Three-Body Problem: t = '</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">time</span><span class="p">[</span><span class="nx">currentIndex</span><span class="p">].</span><span class="nx">toFixed</span><span class="p">(</span><span class="mf">3</span><span class="p">),</span> +<span class="w"> </span><span class="nx">xaxis</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">title</span><span class="o">:</span><span class="w"> </span><span class="s1">'x'</span><span class="p">,</span> +<span class="w"> </span><span class="nx">range</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="mf">1.1</span><span class="p">,</span><span class="mf">1.1</span><span class="p">]</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="nx">yaxis</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">title</span><span class="o">:</span><span class="w"> </span><span class="s1">'y'</span><span class="p">,</span> +<span class="w"> </span><span class="nx">scaleanchor</span><span class="o">:</span><span class="w"> </span><span class="s1">'x'</span><span class="p">,</span> +<span class="w"> </span><span class="nx">scaleratio</span><span class="o">:</span><span class="w"> </span><span class="mf">1</span><span class="p">,</span> +<span class="w"> </span><span class="nx">range</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="mf">0.5</span><span class="p">,</span><span class="mf">0.5</span><span class="p">]</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="nx">plot_bgcolor</span><span class="o">:</span><span class="w"> </span><span class="s1">'black'</span><span class="p">,</span> +<span class="w"> </span><span class="nx">paper_bgcolor</span><span class="o">:</span><span class="w"> </span><span class="s1">'black'</span><span class="p">,</span> +<span class="w"> </span><span class="nx">font</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">color</span><span class="o">:</span><span class="w"> </span><span class="s1">'white'</span><span class="p">,</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="p">};</span> + +<span class="w"> </span><span class="k">try</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">Plotly</span><span class="p">.</span><span class="nx">animate</span><span class="p">(</span><span class="s2">"plot"</span><span class="p">,</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">data</span><span class="o">:</span><span class="w"> </span><span class="nx">data</span><span class="p">,</span><span class="w"> </span><span class="nx">layout</span><span class="o">:</span><span class="w"> </span><span class="nx">layout</span> +<span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">staticPlot</span><span class="o">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span> +<span class="w"> </span><span class="nx">transition</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">duration</span><span class="o">:</span><span class="w"> </span><span class="mf">0</span><span class="p">,</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="nx">frame</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">duration</span><span class="o">:</span><span class="w"> </span><span class="mf">0</span><span class="p">,</span> +<span class="w"> </span><span class="nx">redraw</span><span class="o">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="p">});</span> +<span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">catch</span><span class="w"> </span><span class="p">(</span><span class="nx">err</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">Plotly</span><span class="p">.</span><span class="nx">newPlot</span><span class="p">(</span><span class="s1">'plot'</span><span class="p">,</span><span class="w"> </span><span class="nx">data</span><span class="p">,</span><span class="w"> </span><span class="nx">layout</span><span class="p">);</span> +<span class="w"> </span><span class="p">}</span> + + +<span class="w"> </span><span class="nx">plotIndex</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="nx">delay</span><span class="p">;</span> +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">plotClassic</span><span class="o">===</span><span class="kc">true</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="k">try</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">requestAnimationFrame</span><span class="p">(</span><span class="nx">plotClassicFunc</span><span class="p">);</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="k">catch</span><span class="w"> </span><span class="p">(</span><span class="nx">err</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="p">}</span> + +<span class="w"> </span><span class="p">}</span> +</code></pre> +</div> <h2>"General" N-Body Solver</h2> <h3>Show me the code!</h3> <div class="codehilite"> -<pre><span></span><code><span class="kd">function</span><span class="w"> </span><span class="nx">step</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">3</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">6.67408313131313e-11</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">k1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaR</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">));</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">k2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaR</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">k1</span><span class="p">,</span><span class="w"> </span><span class="mf">0.5</span><span class="p">)),</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">));</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">k3</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaR</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">k2</span><span class="p">,</span><span class="w"> </span><span class="mf">0.5</span><span class="p">)),</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">));</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">k4</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaR</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">k3</span><span class="p">),</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">));</span><span class="w"></span> - -<span class="w"> </span><span class="nx">coords</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">k1</span><span class="p">,</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="mf">2.0</span><span class="p">,</span><span class="w"> </span><span class="nx">k2</span><span class="p">),</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="mf">2.0</span><span class="p">,</span><span class="w"> </span><span class="nx">k3</span><span class="p">),</span><span class="w"> </span><span class="nx">k4</span><span class="p">),</span><span class="w"> </span><span class="mf">1</span><span class="o">/</span><span class="mf">6</span><span class="p">));</span><span class="w"></span> - -<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="nx">coords</span><span class="p">;</span><span class="w"></span> -<span class="p">}</span><span class="w"></span> - -<span class="kd">function</span><span class="w"> </span><span class="nx">detectCollisionsEscape</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">maxSep</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="p">[</span><span class="nx">x</span><span class="p">,</span><span class="w"> </span><span class="nx">y</span><span class="p">,</span><span class="w"> </span><span class="nx">vx</span><span class="p">,</span><span class="w"> </span><span class="nx">vy</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coords</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">V</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">vx</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">v</span><span class="p">,</span><span class="w"> </span><span class="nx">i</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sqrt</span><span class="p">(</span><span class="nx">v</span><span class="w"> </span><span class="o">**</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">vy</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">**</span><span class="w"> </span><span class="mf">2</span><span class="p">));</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">R</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">V</span><span class="p">.</span><span class="nx">map</span><span class="p">(</span><span class="nx">v</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">v</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">deltaT</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">collision</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w"> </span><span class="nx">collisionInds</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">null</span><span class="p">,</span><span class="w"> </span><span class="nx">escape</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w"> </span><span class="nx">escapeInd</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">null</span><span class="p">;</span><span class="w"></span> - -<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kd">let</span><span class="w"> </span><span class="nx">n</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="nx">n</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">x</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span><span class="w"> </span><span class="nx">n</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">rn</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">R</span><span class="p">[</span><span class="nx">n</span><span class="p">],</span><span class="w"> </span><span class="nx">xn</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">x</span><span class="p">[</span><span class="nx">n</span><span class="p">],</span><span class="w"> </span><span class="nx">yn</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">y</span><span class="p">[</span><span class="nx">n</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kd">let</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">x</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">i</span><span class="w"> </span><span class="o">!==</span><span class="w"> </span><span class="nx">n</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">minSep</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">rn</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">R</span><span class="p">[</span><span class="nx">i</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">sep</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sqrt</span><span class="p">((</span><span class="nx">xn</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">x</span><span class="p">[</span><span class="nx">i</span><span class="p">])</span><span class="w"> </span><span class="o">**</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="p">(</span><span class="nx">yn</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">y</span><span class="p">[</span><span class="nx">i</span><span class="p">])</span><span class="w"> </span><span class="o">**</span><span class="w"> </span><span class="mf">2</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">sep</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">minSep</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="nx">collision</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">true</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="nx">collisionInds</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nx">n</span><span class="p">,</span><span class="w"> </span><span class="nx">i</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">sep</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="nx">maxSep</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="nx">escape</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">true</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="nx">escapeInd</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">n</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="p">[</span><span class="nx">collision</span><span class="p">,</span><span class="w"> </span><span class="nx">collisionInds</span><span class="p">,</span><span class="w"> </span><span class="nx">escape</span><span class="p">,</span><span class="w"> </span><span class="nx">escapeInd</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="p">[</span><span class="nx">collision</span><span class="p">,</span><span class="w"> </span><span class="nx">collisionInds</span><span class="p">,</span><span class="w"> </span><span class="nx">escape</span><span class="p">,</span><span class="w"> </span><span class="nx">escapeInd</span><span class="p">];</span><span class="w"></span> -<span class="p">}</span><span class="w"></span> - -<span class="kd">function</span><span class="w"> </span><span class="nx">nBodyStep</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">maxSep</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">6.67408313131313e-11</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="c1">// Similar to our step function before, but keeping track of collisions</span><span class="w"></span> -<span class="w"> </span><span class="nx">coords</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">step</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">);</span><span class="w"> </span><span class="c1">// Update the positions as we did before</span><span class="w"></span> -<span class="w"> </span><span class="c1">//console.log(detectCollisionsEscape(coords, deltaT, maxSep));</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="p">[</span><span class="nx">collision</span><span class="p">,</span><span class="w"> </span><span class="nx">collisionInds</span><span class="p">,</span><span class="w"> </span><span class="nx">escape</span><span class="p">,</span><span class="w"> </span><span class="nx">escapeInd</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">detectCollisionsEscape</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">maxSep</span><span class="p">);</span><span class="w"> </span><span class="c1">// Detect collisions/escapes</span><span class="w"></span> - - -<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">collision</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="c1">// Do inelastic collision and delete extra body (2 -> 1)</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="p">[</span><span class="nx">i1</span><span class="p">,</span><span class="w"> </span><span class="nx">i2</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">collisionInds</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="p">[</span><span class="nx">x1</span><span class="p">,</span><span class="w"> </span><span class="nx">x2</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nx">coords</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">i1</span><span class="p">],</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">i2</span><span class="p">]];</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="p">[</span><span class="nx">y1</span><span class="p">,</span><span class="w"> </span><span class="nx">y2</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nx">coords</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">i1</span><span class="p">],</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">i2</span><span class="p">]];</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="p">[</span><span class="nx">vx1</span><span class="p">,</span><span class="w"> </span><span class="nx">vx2</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nx">coords</span><span class="p">[</span><span class="mf">2</span><span class="p">][</span><span class="nx">i1</span><span class="p">],</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">2</span><span class="p">][</span><span class="nx">i2</span><span class="p">]];</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="p">[</span><span class="nx">vy1</span><span class="p">,</span><span class="w"> </span><span class="nx">vy2</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nx">coords</span><span class="p">[</span><span class="mf">3</span><span class="p">][</span><span class="nx">i1</span><span class="p">],</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">3</span><span class="p">][</span><span class="nx">i2</span><span class="p">]];</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="p">[</span><span class="nx">px1</span><span class="p">,</span><span class="w"> </span><span class="nx">px2</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nx">masses</span><span class="p">[</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">vx1</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i2</span><span class="p">]</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">vx2</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="p">[</span><span class="nx">py1</span><span class="p">,</span><span class="w"> </span><span class="nx">py2</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nx">masses</span><span class="p">[</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">vy1</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i2</span><span class="p">]</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">vy2</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">px</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">px1</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">px2</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">py</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">py1</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">py2</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">newM</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i2</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">vfx</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">px</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nx">newM</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">vfy</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">py</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nx">newM</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="nx">x1</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">x2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i2</span><span class="p">])</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="p">(</span><span class="nx">masses</span><span class="p">[</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i2</span><span class="p">]);</span><span class="w"> </span><span class="c1">// Center of mass</span><span class="w"></span> -<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="nx">y1</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">y2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i2</span><span class="p">])</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="p">(</span><span class="nx">masses</span><span class="p">[</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i2</span><span class="p">]);</span><span class="w"></span> -<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">2</span><span class="p">][</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">vfx</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">3</span><span class="p">][</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">vfy</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">0</span><span class="p">].</span><span class="nx">splice</span><span class="p">(</span><span class="nx">i2</span><span class="p">,</span><span class="w"> </span><span class="mf">1</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">1</span><span class="p">].</span><span class="nx">splice</span><span class="p">(</span><span class="nx">i2</span><span class="p">,</span><span class="w"> </span><span class="mf">1</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">2</span><span class="p">].</span><span class="nx">splice</span><span class="p">(</span><span class="nx">i2</span><span class="p">,</span><span class="w"> </span><span class="mf">1</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">3</span><span class="p">].</span><span class="nx">splice</span><span class="p">(</span><span class="nx">i2</span><span class="p">,</span><span class="w"> </span><span class="mf">1</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">newM</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="nx">masses</span><span class="p">.</span><span class="nx">splice</span><span class="p">(</span><span class="nx">i2</span><span class="p">,</span><span class="w"> </span><span class="mf">1</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="nx">nBodies</span><span class="o">--</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="w"> </span><span class="c1">// Could also implement condition for escape where we stop calculating forces but I'm too lazy for now</span><span class="w"></span> -<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="p">[</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">collision</span><span class="p">,</span><span class="w"> </span><span class="nx">collisionInds</span><span class="p">,</span><span class="w"> </span><span class="nx">escape</span><span class="p">,</span><span class="w"> </span><span class="nx">escapeInd</span><span class="p">];</span><span class="w"></span> -<span class="p">}</span><span class="w"></span> - -<span class="kd">function</span><span class="w"> </span><span class="nx">uniform</span><span class="p">(</span><span class="nx">min</span><span class="p">,</span><span class="w"> </span><span class="nx">max</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">random</span><span class="p">()</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="p">(</span><span class="nx">max</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">min</span><span class="p">)</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">min</span><span class="p">;</span><span class="w"></span> -<span class="p">}</span><span class="w"></span> - -<span class="kd">function</span><span class="w"> </span><span class="nx">deepCopyCoordsArray</span><span class="p">(</span><span class="nx">arr</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="nx">arr</span><span class="p">.</span><span class="nx">map</span><span class="p">(</span><span class="nx">innerArr</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">innerArr</span><span class="p">.</span><span class="nx">slice</span><span class="p">());</span><span class="w"></span> -<span class="p">}</span><span class="w"></span> - -<span class="kd">function</span><span class="w"> </span><span class="nx">genNBodyResults</span><span class="p">(</span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">tStop</span><span class="p">,</span><span class="w"> </span><span class="nx">nTPts</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodiesStop</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">10</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">6.67408313131313e-11</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> - -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">btn</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s2">"startSim3"</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="c1">// Set button text to Solving</span><span class="w"></span> -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">prevText</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">btn</span><span class="p">.</span><span class="nx">innerHTML</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="nx">btn</span><span class="p">.</span><span class="nx">innerHTML</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"Solving..."</span><span class="p">;</span><span class="w"></span> - -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">coords</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nb">Array</span><span class="p">(</span><span class="nx">nBodies</span><span class="p">).</span><span class="nx">fill</span><span class="p">(</span><span class="mf">0</span><span class="p">),</span><span class="w"> </span><span class="nb">Array</span><span class="p">(</span><span class="nx">nBodies</span><span class="p">).</span><span class="nx">fill</span><span class="p">(</span><span class="mf">0</span><span class="p">),</span><span class="w"> </span><span class="nb">Array</span><span class="p">(</span><span class="nx">nBodies</span><span class="p">).</span><span class="nx">fill</span><span class="p">(</span><span class="mf">0</span><span class="p">),</span><span class="w"> </span><span class="nb">Array</span><span class="p">(</span><span class="nx">nBodies</span><span class="p">).</span><span class="nx">fill</span><span class="p">(</span><span class="mf">0</span><span class="p">)];</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">Mstar</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">2e30</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">Mp</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">Mstar</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">1e4</span><span class="p">;</span><span class="w"></span> - -<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kd">let</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="c1">// Initialize coordinates on ~Keplerian orbits</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">accept</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">false</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">r</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">null</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="k">while</span><span class="w"> </span><span class="p">(</span><span class="o">!</span><span class="nx">accept</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="c1">// Prevent a particle from spawning within 0.2 AU too close to "star"</span><span class="w"></span> -<span class="w"> </span><span class="nx">r</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">random</span><span class="p">()</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">1.5e11</span><span class="p">;</span><span class="w"> </span><span class="c1">// Say radius of 2 AU</span><span class="w"></span> -<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">r</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">1.5e11</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="mf">0.2</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="nx">accept</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">true</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">theta</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">uniform</span><span class="p">(</span><span class="mf">0</span><span class="p">,</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">PI</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">r</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">cos</span><span class="p">(</span><span class="nx">theta</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">y</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">r</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sin</span><span class="p">(</span><span class="nx">theta</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">v</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sqrt</span><span class="p">(</span><span class="nx">G</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">Mstar</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nx">r</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">perturbedV</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">v</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">v</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">1000</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">uniform</span><span class="p">(</span><span class="o">-</span><span class="mf">1</span><span class="p">,</span><span class="w"> </span><span class="mf">1</span><span class="p">);</span><span class="w"> </span><span class="c1">// Perturb the velocities ever so slightly</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">vTheta</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">atan2</span><span class="p">(</span><span class="nx">y</span><span class="p">,</span><span class="w"> </span><span class="nx">x</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">x</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">y</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">2</span><span class="p">][</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">-</span><span class="nx">perturbedV</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sin</span><span class="p">(</span><span class="nx">vTheta</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">3</span><span class="p">][</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">perturbedV</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">cos</span><span class="p">(</span><span class="nx">vTheta</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> - -<span class="w"> </span><span class="c1">//console.log('Initial coords:', coords);</span><span class="w"></span> - - -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">masses</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Array</span><span class="p">(</span><span class="nx">nBodies</span><span class="p">).</span><span class="nx">fill</span><span class="p">(</span><span class="nx">Mp</span><span class="p">);</span><span class="w"> </span><span class="c1">// Initialize masses</span><span class="w"></span> -<span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">Mstar</span><span class="p">;</span><span class="w"> </span><span class="c1">// Make index one special as the central star</span><span class="w"></span> -<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">2</span><span class="p">][</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">3</span><span class="p">][</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="c1">// Initialize central star at origin with no velocity</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">yearSec</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">365</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">24</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">3600</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">time</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Array</span><span class="p">.</span><span class="kr">from</span><span class="p">({</span><span class="w"> </span><span class="nx">length</span><span class="o">:</span><span class="w"> </span><span class="nx">nTPts</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="p">(</span><span class="nx">_</span><span class="p">,</span><span class="w"> </span><span class="nx">i</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">tStop</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="p">(</span><span class="nx">nTPts</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mf">1</span><span class="p">)</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">yearSec</span><span class="p">);</span><span class="w"> </span><span class="c1">// Years -> s</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">t</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">time</span><span class="p">[</span><span class="mf">0</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">deltaT</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">time</span><span class="p">[</span><span class="mf">1</span><span class="p">]</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">time</span><span class="p">[</span><span class="mf">0</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">tInd</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">coordsRecord</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nx">deepCopyCoordsArray</span><span class="p">(</span><span class="nx">coords</span><span class="p">)];</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">massRecord</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nx">masses</span><span class="p">.</span><span class="nx">slice</span><span class="p">()];</span><span class="w"> </span><span class="c1">// Initialize records with initial conditions</span><span class="w"></span> - - -<span class="w"> </span><span class="k">while</span><span class="w"> </span><span class="p">(</span><span class="nx">tInd</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">nTPts</span><span class="w"> </span><span class="o">&&</span><span class="w"> </span><span class="nx">nBodies</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="nx">nBodiesStop</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="c1">//console.log('Initial coords:', coords);</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">nBodyStep</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="mf">10</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">1.5e11</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">);</span><span class="w"> </span><span class="c1">// Update</span><span class="w"></span> -<span class="w"> </span><span class="nx">coordsRecord</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">deepCopyCoordsArray</span><span class="p">(</span><span class="nx">coords</span><span class="p">));</span><span class="w"></span> -<span class="w"> </span><span class="nx">massRecord</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">masses</span><span class="p">.</span><span class="nx">slice</span><span class="p">());</span><span class="w"> </span><span class="c1">// Add to records</span><span class="w"></span> -<span class="w"> </span><span class="nx">tInd</span><span class="o">++</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="nx">t</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">time</span><span class="p">[</span><span class="nx">tInd</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="c1">//console.log(`currently at t = ${(t / yearSec).toFixed(2)} years\r`);</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="w"> </span><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="sb">`final time = </span><span class="si">${</span><span class="nx">time</span><span class="p">[</span><span class="nx">tInd</span><span class="p">]</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nx">yearSec</span><span class="si">}</span><span class="sb"> years with </span><span class="si">${</span><span class="nx">nBodies</span><span class="si">}</span><span class="sb"> bodies remaining`</span><span class="p">);</span><span class="w"></span> - -<span class="w"> </span><span class="c1">// Set button text to Start Simulation</span><span class="w"></span> -<span class="w"> </span><span class="nx">btn</span><span class="p">.</span><span class="nx">innerHTML</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">prevText</span><span class="p">;</span><span class="w"></span> - -<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="p">[</span><span class="nx">coordsRecord</span><span class="p">,</span><span class="w"> </span><span class="nx">massRecord</span><span class="p">,</span><span class="w"> </span><span class="nx">time</span><span class="p">.</span><span class="nx">slice</span><span class="p">(</span><span class="mf">0</span><span class="p">,</span><span class="w"> </span><span class="nx">tInd</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mf">1</span><span class="p">)];</span><span class="w"></span> -<span class="p">}</span><span class="w"></span> - - -<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="p">[</span><span class="nx">coordsRecordR</span><span class="p">,</span><span class="w"> </span><span class="nx">_</span><span class="p">,</span><span class="w"> </span><span class="nx">tR</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">genNBodyResults</span><span class="p">(</span><span class="mf">256</span><span class="p">,</span><span class="mf">1</span><span class="p">,</span><span class="mf">1001</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="c1">//console.log(coordsRecordR);</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">yearSec</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">365</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">24</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">3600</span><span class="p">;</span><span class="w"></span> - -<span class="w"> </span><span class="kd">function</span><span class="w"> </span><span class="nx">createFrame</span><span class="p">(</span><span class="nx">coordsR</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="o">!</span><span class="nx">coordsR</span><span class="w"> </span><span class="o">||</span><span class="w"> </span><span class="o">!</span><span class="nx">coordsR</span><span class="p">[</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">||</span><span class="w"> </span><span class="o">!</span><span class="nx">coordsR</span><span class="p">[</span><span class="mf">1</span><span class="p">])</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="p">[];</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> - -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">traceCentralStar</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="nx">coordsR</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">1.5e11</span><span class="p">],</span><span class="w"></span> -<span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="nx">coordsR</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">1.5e11</span><span class="p">],</span><span class="w"></span> -<span class="w"> </span><span class="nx">mode</span><span class="o">:</span><span class="w"> </span><span class="s1">'markers'</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="nx">type</span><span class="o">:</span><span class="w"> </span><span class="s1">'scatter'</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="nx">name</span><span class="o">:</span><span class="w"> </span><span class="s1">'Central star'</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="nx">marker</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">color</span><span class="o">:</span><span class="w"> </span><span class="s1">'gold'</span><span class="p">,</span><span class="w"> </span><span class="nx">symbol</span><span class="o">:</span><span class="w"> </span><span class="s1">'star'</span><span class="p">,</span><span class="w"> </span><span class="nx">size</span><span class="o">:</span><span class="w"> </span><span class="mf">10</span><span class="w"> </span><span class="p">},</span><span class="w"></span> -<span class="w"> </span><span class="p">};</span><span class="w"></span> - -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">xCoords</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coordsR</span><span class="p">[</span><span class="mf">0</span><span class="p">].</span><span class="nx">slice</span><span class="p">(</span><span class="mf">1</span><span class="p">).</span><span class="nx">map</span><span class="p">(</span><span class="nx">x</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">x</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">1.5e11</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">yCoords</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coordsR</span><span class="p">[</span><span class="mf">1</span><span class="p">].</span><span class="nx">slice</span><span class="p">(</span><span class="mf">1</span><span class="p">).</span><span class="nx">map</span><span class="p">(</span><span class="nx">y</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">y</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">1.5e11</span><span class="p">);</span><span class="w"></span> - -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">traceOtherBodies</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="nx">xCoords</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="nx">yCoords</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="nx">mode</span><span class="o">:</span><span class="w"> </span><span class="s1">'markers'</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="nx">type</span><span class="o">:</span><span class="w"> </span><span class="s1">'scatter'</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="nx">name</span><span class="o">:</span><span class="w"> </span><span class="s1">''</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="nx">marker</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">color</span><span class="o">:</span><span class="w"> </span><span class="s1">'dodgerblue'</span><span class="p">,</span><span class="w"> </span><span class="nx">symbol</span><span class="o">:</span><span class="w"> </span><span class="s1">'circle'</span><span class="p">,</span><span class="w"> </span><span class="nx">size</span><span class="o">:</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="p">},</span><span class="w"></span> -<span class="w"> </span><span class="p">};</span><span class="w"></span> - -<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="p">[</span><span class="nx">traceCentralStar</span><span class="p">,</span><span class="w"> </span><span class="nx">traceOtherBodies</span><span class="p">];</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> - - -<span class="w"> </span><span class="kd">function</span><span class="w"> </span><span class="nx">createLayout</span><span class="p">(</span><span class="nx">i</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="nx">title</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="nx">text</span><span class="o">:</span><span class="w"> </span><span class="sb">`N-Body Problem: t = </span><span class="si">${</span><span class="nb">Number</span><span class="p">(</span><span class="nx">t</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nx">yearSec</span><span class="p">).</span><span class="nx">toFixed</span><span class="p">(</span><span class="mf">3</span><span class="p">)</span><span class="si">}</span><span class="sb"> years`</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="mf">0.03</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="mf">0.97</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="nx">xanchor</span><span class="o">:</span><span class="w"> </span><span class="s1">'left'</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="nx">yanchor</span><span class="o">:</span><span class="w"> </span><span class="s1">'top'</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="nx">font</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">size</span><span class="o">:</span><span class="w"> </span><span class="mf">14</span><span class="w"> </span><span class="p">},</span><span class="w"></span> -<span class="w"> </span><span class="p">},</span><span class="w"></span> -<span class="w"> </span><span class="nx">xaxis</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">title</span><span class="o">:</span><span class="w"> </span><span class="s1">'x [AU]'</span><span class="p">,</span><span class="w"> </span><span class="nx">range</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="mf">2.1</span><span class="p">,</span><span class="w"> </span><span class="mf">2.1</span><span class="p">]</span><span class="w"> </span><span class="p">},</span><span class="w"></span> -<span class="w"> </span><span class="nx">yaxis</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">title</span><span class="o">:</span><span class="w"> </span><span class="s1">'y [AU]'</span><span class="p">,</span><span class="w"> </span><span class="nx">range</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="mf">2.1</span><span class="p">,</span><span class="w"> </span><span class="mf">2.1</span><span class="p">],</span><span class="w"> </span><span class="nx">scaleanchor</span><span class="o">:</span><span class="w"> </span><span class="s1">'x'</span><span class="p">,</span><span class="w"> </span><span class="nx">scaleratio</span><span class="o">:</span><span class="w"> </span><span class="mf">1</span><span class="w"> </span><span class="p">},</span><span class="w"></span> -<span class="w"> </span><span class="nx">showlegend</span><span class="o">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="nx">margin</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">l</span><span class="o">:</span><span class="w"> </span><span class="mf">60</span><span class="p">,</span><span class="w"> </span><span class="nx">r</span><span class="o">:</span><span class="w"> </span><span class="mf">40</span><span class="p">,</span><span class="w"> </span><span class="nx">t</span><span class="o">:</span><span class="w"> </span><span class="mf">40</span><span class="p">,</span><span class="w"> </span><span class="nx">b</span><span class="o">:</span><span class="w"> </span><span class="mf">40</span><span class="w"> </span><span class="p">},</span><span class="w"></span> -<span class="w"> </span><span class="nx">width</span><span class="o">:</span><span class="w"> </span><span class="mf">800</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="nx">height</span><span class="o">:</span><span class="w"> </span><span class="mf">800</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="nx">plot_bgcolor</span><span class="o">:</span><span class="w"> </span><span class="s1">'black'</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="p">};</span><span class="w"></span> -<span class="p">}</span><span class="w"></span> - -<span class="w"> </span><span class="kd">function</span><span class="w"> </span><span class="nx">animateNBodyProblem</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">nFrames</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">tR</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span><span class="w"></span> - -<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kd">let</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">nFrames</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">frameData</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">createFrame</span><span class="p">(</span><span class="nx">coordsRecordR</span><span class="p">[</span><span class="nx">i</span><span class="p">]);</span><span class="w"></span> -<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">layout</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">createLayout</span><span class="p">(</span><span class="nx">i</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="c1">//Plotly.newPlot(plotDiv, frameData, layout);</span><span class="w"></span> -<span class="w"> </span><span class="k">try</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="nx">Plotly</span><span class="p">.</span><span class="nx">animate</span><span class="p">(</span><span class="s2">"plot"</span><span class="p">,</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="nx">data</span><span class="o">:</span><span class="w"> </span><span class="nx">frameData</span><span class="p">,</span><span class="w"> </span><span class="nx">layout</span><span class="o">:</span><span class="w"> </span><span class="nx">layout</span><span class="w"></span> -<span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="nx">staticPlot</span><span class="o">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="nx">transition</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="nx">duration</span><span class="o">:</span><span class="w"> </span><span class="mf">0</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="p">},</span><span class="w"></span> -<span class="w"> </span><span class="nx">frame</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="nx">duration</span><span class="o">:</span><span class="w"> </span><span class="mf">0</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="nx">redraw</span><span class="o">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="w"> </span><span class="p">});</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">catch</span><span class="w"> </span><span class="p">(</span><span class="nx">err</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="nx">Plotly</span><span class="p">.</span><span class="nx">newPlot</span><span class="p">(</span><span class="s1">'plot'</span><span class="p">,</span><span class="w"> </span><span class="nx">frameData</span><span class="p">,</span><span class="w"> </span><span class="nx">layout</span><span class="p">);</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="w"> </span><span class="p">}</span><span class="w"></span> -<span class="p">}</span><span class="w"></span> - -<span class="nx">animateNBodyProblem</span><span class="p">();</span><span class="w"></span> +<pre><span></span><code><span class="kd">function</span><span class="w"> </span><span class="nx">step</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">3</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">6.67408313131313e-11</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">k1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaR</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">));</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">k2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaR</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">k1</span><span class="p">,</span><span class="w"> </span><span class="mf">0.5</span><span class="p">)),</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">));</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">k3</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaR</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">k2</span><span class="p">,</span><span class="w"> </span><span class="mf">0.5</span><span class="p">)),</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">));</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">k4</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaR</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">k3</span><span class="p">),</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">));</span> + +<span class="w"> </span><span class="nx">coords</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">k1</span><span class="p">,</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="mf">2.0</span><span class="p">,</span><span class="w"> </span><span class="nx">k2</span><span class="p">),</span><span class="w"> </span><span class="nx">math</span><span class="p">.</span><span class="nx">multiply</span><span class="p">(</span><span class="mf">2.0</span><span class="p">,</span><span class="w"> </span><span class="nx">k3</span><span class="p">),</span><span class="w"> </span><span class="nx">k4</span><span class="p">),</span><span class="w"> </span><span class="mf">1</span><span class="o">/</span><span class="mf">6</span><span class="p">));</span> + +<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="nx">coords</span><span class="p">;</span> +<span class="p">}</span> + +<span class="kd">function</span><span class="w"> </span><span class="nx">detectCollisionsEscape</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">maxSep</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="p">[</span><span class="nx">x</span><span class="p">,</span><span class="w"> </span><span class="nx">y</span><span class="p">,</span><span class="w"> </span><span class="nx">vx</span><span class="p">,</span><span class="w"> </span><span class="nx">vy</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coords</span><span class="p">;</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">V</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">vx</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">v</span><span class="p">,</span><span class="w"> </span><span class="nx">i</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sqrt</span><span class="p">(</span><span class="nx">v</span><span class="w"> </span><span class="o">**</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">vy</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">**</span><span class="w"> </span><span class="mf">2</span><span class="p">));</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">R</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">V</span><span class="p">.</span><span class="nx">map</span><span class="p">(</span><span class="nx">v</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">v</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">deltaT</span><span class="p">);</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">collision</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w"> </span><span class="nx">collisionInds</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">null</span><span class="p">,</span><span class="w"> </span><span class="nx">escape</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w"> </span><span class="nx">escapeInd</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">null</span><span class="p">;</span> + +<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kd">let</span><span class="w"> </span><span class="nx">n</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="nx">n</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">x</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span><span class="w"> </span><span class="nx">n</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">rn</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">R</span><span class="p">[</span><span class="nx">n</span><span class="p">],</span><span class="w"> </span><span class="nx">xn</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">x</span><span class="p">[</span><span class="nx">n</span><span class="p">],</span><span class="w"> </span><span class="nx">yn</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">y</span><span class="p">[</span><span class="nx">n</span><span class="p">];</span> +<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kd">let</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">x</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">i</span><span class="w"> </span><span class="o">!==</span><span class="w"> </span><span class="nx">n</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">minSep</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">rn</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">R</span><span class="p">[</span><span class="nx">i</span><span class="p">];</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">sep</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sqrt</span><span class="p">((</span><span class="nx">xn</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">x</span><span class="p">[</span><span class="nx">i</span><span class="p">])</span><span class="w"> </span><span class="o">**</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="p">(</span><span class="nx">yn</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">y</span><span class="p">[</span><span class="nx">i</span><span class="p">])</span><span class="w"> </span><span class="o">**</span><span class="w"> </span><span class="mf">2</span><span class="p">);</span> +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">sep</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">minSep</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">collision</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">true</span><span class="p">;</span> +<span class="w"> </span><span class="nx">collisionInds</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nx">n</span><span class="p">,</span><span class="w"> </span><span class="nx">i</span><span class="p">];</span> +<span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">sep</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="nx">maxSep</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">escape</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">true</span><span class="p">;</span> +<span class="w"> </span><span class="nx">escapeInd</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">n</span><span class="p">;</span> +<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="p">[</span><span class="nx">collision</span><span class="p">,</span><span class="w"> </span><span class="nx">collisionInds</span><span class="p">,</span><span class="w"> </span><span class="nx">escape</span><span class="p">,</span><span class="w"> </span><span class="nx">escapeInd</span><span class="p">];</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="p">[</span><span class="nx">collision</span><span class="p">,</span><span class="w"> </span><span class="nx">collisionInds</span><span class="p">,</span><span class="w"> </span><span class="nx">escape</span><span class="p">,</span><span class="w"> </span><span class="nx">escapeInd</span><span class="p">];</span> +<span class="p">}</span> + +<span class="kd">function</span><span class="w"> </span><span class="nx">nBodyStep</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">maxSep</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">6.67408313131313e-11</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="c1">// Similar to our step function before, but keeping track of collisions</span> +<span class="w"> </span><span class="nx">coords</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">step</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">);</span><span class="w"> </span><span class="c1">// Update the positions as we did before</span> +<span class="w"> </span><span class="c1">//console.log(detectCollisionsEscape(coords, deltaT, maxSep));</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="p">[</span><span class="nx">collision</span><span class="p">,</span><span class="w"> </span><span class="nx">collisionInds</span><span class="p">,</span><span class="w"> </span><span class="nx">escape</span><span class="p">,</span><span class="w"> </span><span class="nx">escapeInd</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">detectCollisionsEscape</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="nx">maxSep</span><span class="p">);</span><span class="w"> </span><span class="c1">// Detect collisions/escapes</span> + + +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">collision</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="c1">// Do inelastic collision and delete extra body (2 -> 1)</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="p">[</span><span class="nx">i1</span><span class="p">,</span><span class="w"> </span><span class="nx">i2</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">collisionInds</span><span class="p">;</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="p">[</span><span class="nx">x1</span><span class="p">,</span><span class="w"> </span><span class="nx">x2</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nx">coords</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">i1</span><span class="p">],</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">i2</span><span class="p">]];</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="p">[</span><span class="nx">y1</span><span class="p">,</span><span class="w"> </span><span class="nx">y2</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nx">coords</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">i1</span><span class="p">],</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">i2</span><span class="p">]];</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="p">[</span><span class="nx">vx1</span><span class="p">,</span><span class="w"> </span><span class="nx">vx2</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nx">coords</span><span class="p">[</span><span class="mf">2</span><span class="p">][</span><span class="nx">i1</span><span class="p">],</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">2</span><span class="p">][</span><span class="nx">i2</span><span class="p">]];</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="p">[</span><span class="nx">vy1</span><span class="p">,</span><span class="w"> </span><span class="nx">vy2</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nx">coords</span><span class="p">[</span><span class="mf">3</span><span class="p">][</span><span class="nx">i1</span><span class="p">],</span><span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">3</span><span class="p">][</span><span class="nx">i2</span><span class="p">]];</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="p">[</span><span class="nx">px1</span><span class="p">,</span><span class="w"> </span><span class="nx">px2</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nx">masses</span><span class="p">[</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">vx1</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i2</span><span class="p">]</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">vx2</span><span class="p">];</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="p">[</span><span class="nx">py1</span><span class="p">,</span><span class="w"> </span><span class="nx">py2</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nx">masses</span><span class="p">[</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">vy1</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i2</span><span class="p">]</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">vy2</span><span class="p">];</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">px</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">px1</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">px2</span><span class="p">;</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">py</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">py1</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">py2</span><span class="p">;</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">newM</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i2</span><span class="p">];</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">vfx</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">px</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nx">newM</span><span class="p">;</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">vfy</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">py</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nx">newM</span><span class="p">;</span> +<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="nx">x1</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">x2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i2</span><span class="p">])</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="p">(</span><span class="nx">masses</span><span class="p">[</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i2</span><span class="p">]);</span><span class="w"> </span><span class="c1">// Center of mass</span> +<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="nx">y1</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">y2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i2</span><span class="p">])</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="p">(</span><span class="nx">masses</span><span class="p">[</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i2</span><span class="p">]);</span> +<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">2</span><span class="p">][</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">vfx</span><span class="p">;</span> +<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">3</span><span class="p">][</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">vfy</span><span class="p">;</span> +<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">0</span><span class="p">].</span><span class="nx">splice</span><span class="p">(</span><span class="nx">i2</span><span class="p">,</span><span class="w"> </span><span class="mf">1</span><span class="p">);</span> +<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">1</span><span class="p">].</span><span class="nx">splice</span><span class="p">(</span><span class="nx">i2</span><span class="p">,</span><span class="w"> </span><span class="mf">1</span><span class="p">);</span> +<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">2</span><span class="p">].</span><span class="nx">splice</span><span class="p">(</span><span class="nx">i2</span><span class="p">,</span><span class="w"> </span><span class="mf">1</span><span class="p">);</span> +<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">3</span><span class="p">].</span><span class="nx">splice</span><span class="p">(</span><span class="nx">i2</span><span class="p">,</span><span class="w"> </span><span class="mf">1</span><span class="p">);</span> +<span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="nx">i1</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">newM</span><span class="p">;</span> +<span class="w"> </span><span class="nx">masses</span><span class="p">.</span><span class="nx">splice</span><span class="p">(</span><span class="nx">i2</span><span class="p">,</span><span class="w"> </span><span class="mf">1</span><span class="p">);</span> +<span class="w"> </span><span class="nx">nBodies</span><span class="o">--</span><span class="p">;</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="c1">// Could also implement condition for escape where we stop calculating forces but I'm too lazy for now</span> +<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="p">[</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">collision</span><span class="p">,</span><span class="w"> </span><span class="nx">collisionInds</span><span class="p">,</span><span class="w"> </span><span class="nx">escape</span><span class="p">,</span><span class="w"> </span><span class="nx">escapeInd</span><span class="p">];</span> +<span class="p">}</span> + +<span class="kd">function</span><span class="w"> </span><span class="nx">uniform</span><span class="p">(</span><span class="nx">min</span><span class="p">,</span><span class="w"> </span><span class="nx">max</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">random</span><span class="p">()</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="p">(</span><span class="nx">max</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">min</span><span class="p">)</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">min</span><span class="p">;</span> +<span class="p">}</span> + +<span class="kd">function</span><span class="w"> </span><span class="nx">deepCopyCoordsArray</span><span class="p">(</span><span class="nx">arr</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="nx">arr</span><span class="p">.</span><span class="nx">map</span><span class="p">(</span><span class="nx">innerArr</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">innerArr</span><span class="p">.</span><span class="nx">slice</span><span class="p">());</span> +<span class="p">}</span> + +<span class="kd">function</span><span class="w"> </span><span class="nx">genNBodyResults</span><span class="p">(</span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">tStop</span><span class="p">,</span><span class="w"> </span><span class="nx">nTPts</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodiesStop</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">10</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">6.67408313131313e-11</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> + +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">btn</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s2">"startSim3"</span><span class="p">);</span> +<span class="w"> </span><span class="c1">// Set button text to Solving</span> +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">prevText</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">btn</span><span class="p">.</span><span class="nx">innerHTML</span><span class="p">;</span> +<span class="w"> </span><span class="nx">btn</span><span class="p">.</span><span class="nx">innerHTML</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"Solving..."</span><span class="p">;</span> + +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">coords</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nb">Array</span><span class="p">(</span><span class="nx">nBodies</span><span class="p">).</span><span class="nx">fill</span><span class="p">(</span><span class="mf">0</span><span class="p">),</span><span class="w"> </span><span class="nb">Array</span><span class="p">(</span><span class="nx">nBodies</span><span class="p">).</span><span class="nx">fill</span><span class="p">(</span><span class="mf">0</span><span class="p">),</span><span class="w"> </span><span class="nb">Array</span><span class="p">(</span><span class="nx">nBodies</span><span class="p">).</span><span class="nx">fill</span><span class="p">(</span><span class="mf">0</span><span class="p">),</span><span class="w"> </span><span class="nb">Array</span><span class="p">(</span><span class="nx">nBodies</span><span class="p">).</span><span class="nx">fill</span><span class="p">(</span><span class="mf">0</span><span class="p">)];</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">Mstar</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">2e30</span><span class="p">;</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">Mp</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">Mstar</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">1e4</span><span class="p">;</span> + +<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kd">let</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="c1">// Initialize coordinates on ~Keplerian orbits</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">accept</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">false</span><span class="p">;</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">r</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">null</span><span class="p">;</span> +<span class="w"> </span><span class="k">while</span><span class="w"> </span><span class="p">(</span><span class="o">!</span><span class="nx">accept</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="c1">// Prevent a particle from spawning within 0.2 AU too close to "star"</span> +<span class="w"> </span><span class="nx">r</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">random</span><span class="p">()</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">1.5e11</span><span class="p">;</span><span class="w"> </span><span class="c1">// Say radius of 2 AU</span> +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">r</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">1.5e11</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="mf">0.2</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">accept</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">true</span><span class="p">;</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">theta</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">uniform</span><span class="p">(</span><span class="mf">0</span><span class="p">,</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">PI</span><span class="p">);</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">r</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">cos</span><span class="p">(</span><span class="nx">theta</span><span class="p">);</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">y</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">r</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sin</span><span class="p">(</span><span class="nx">theta</span><span class="p">);</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">v</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sqrt</span><span class="p">(</span><span class="nx">G</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">Mstar</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nx">r</span><span class="p">);</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">perturbedV</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">v</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nx">v</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">1000</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">uniform</span><span class="p">(</span><span class="o">-</span><span class="mf">1</span><span class="p">,</span><span class="w"> </span><span class="mf">1</span><span class="p">);</span><span class="w"> </span><span class="c1">// Perturb the velocities ever so slightly</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">vTheta</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">atan2</span><span class="p">(</span><span class="nx">y</span><span class="p">,</span><span class="w"> </span><span class="nx">x</span><span class="p">);</span> +<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">x</span><span class="p">;</span> +<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">y</span><span class="p">;</span> +<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">2</span><span class="p">][</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">-</span><span class="nx">perturbedV</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">sin</span><span class="p">(</span><span class="nx">vTheta</span><span class="p">);</span> +<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">3</span><span class="p">][</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">perturbedV</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">cos</span><span class="p">(</span><span class="nx">vTheta</span><span class="p">);</span> +<span class="w"> </span><span class="p">}</span> + +<span class="w"> </span><span class="c1">//console.log('Initial coords:', coords);</span> + + +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">masses</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Array</span><span class="p">(</span><span class="nx">nBodies</span><span class="p">).</span><span class="nx">fill</span><span class="p">(</span><span class="nx">Mp</span><span class="p">);</span><span class="w"> </span><span class="c1">// Initialize masses</span> +<span class="w"> </span><span class="nx">masses</span><span class="p">[</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">Mstar</span><span class="p">;</span><span class="w"> </span><span class="c1">// Make index one special as the central star</span> +<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span> +<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span> +<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">2</span><span class="p">][</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span> +<span class="w"> </span><span class="nx">coords</span><span class="p">[</span><span class="mf">3</span><span class="p">][</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="c1">// Initialize central star at origin with no velocity</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">yearSec</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">365</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">24</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">3600</span><span class="p">;</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">time</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Array</span><span class="p">.</span><span class="kr">from</span><span class="p">({</span><span class="w"> </span><span class="nx">length</span><span class="o">:</span><span class="w"> </span><span class="nx">nTPts</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="p">(</span><span class="nx">_</span><span class="p">,</span><span class="w"> </span><span class="nx">i</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">tStop</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="p">(</span><span class="nx">nTPts</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mf">1</span><span class="p">)</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nx">yearSec</span><span class="p">);</span><span class="w"> </span><span class="c1">// Years -> s</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">t</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">time</span><span class="p">[</span><span class="mf">0</span><span class="p">];</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">deltaT</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">time</span><span class="p">[</span><span class="mf">1</span><span class="p">]</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="nx">time</span><span class="p">[</span><span class="mf">0</span><span class="p">];</span> +<span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nx">tInd</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">coordsRecord</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nx">deepCopyCoordsArray</span><span class="p">(</span><span class="nx">coords</span><span class="p">)];</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">massRecord</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="nx">masses</span><span class="p">.</span><span class="nx">slice</span><span class="p">()];</span><span class="w"> </span><span class="c1">// Initialize records with initial conditions</span> + + +<span class="w"> </span><span class="k">while</span><span class="w"> </span><span class="p">(</span><span class="nx">tInd</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">nTPts</span><span class="w"> </span><span class="o">&&</span><span class="w"> </span><span class="nx">nBodies</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="nx">nBodiesStop</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="c1">//console.log('Initial coords:', coords);</span> +<span class="w"> </span><span class="p">[</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">nBodyStep</span><span class="p">(</span><span class="nx">coords</span><span class="p">,</span><span class="w"> </span><span class="nx">masses</span><span class="p">,</span><span class="w"> </span><span class="nx">deltaT</span><span class="p">,</span><span class="w"> </span><span class="mf">10</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">1.5e11</span><span class="p">,</span><span class="w"> </span><span class="nx">nBodies</span><span class="p">,</span><span class="w"> </span><span class="nx">G</span><span class="p">);</span><span class="w"> </span><span class="c1">// Update</span> +<span class="w"> </span><span class="nx">coordsRecord</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">deepCopyCoordsArray</span><span class="p">(</span><span class="nx">coords</span><span class="p">));</span> +<span class="w"> </span><span class="nx">massRecord</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">masses</span><span class="p">.</span><span class="nx">slice</span><span class="p">());</span><span class="w"> </span><span class="c1">// Add to records</span> +<span class="w"> </span><span class="nx">tInd</span><span class="o">++</span><span class="p">;</span> +<span class="w"> </span><span class="nx">t</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">time</span><span class="p">[</span><span class="nx">tInd</span><span class="p">];</span> +<span class="w"> </span><span class="c1">//console.log(`currently at t = ${(t / yearSec).toFixed(2)} years\r`);</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="sb">`final time = </span><span class="si">${</span><span class="nx">time</span><span class="p">[</span><span class="nx">tInd</span><span class="p">]</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nx">yearSec</span><span class="si">}</span><span class="sb"> years with </span><span class="si">${</span><span class="nx">nBodies</span><span class="si">}</span><span class="sb"> bodies remaining`</span><span class="p">);</span> + +<span class="w"> </span><span class="c1">// Set button text to Start Simulation</span> +<span class="w"> </span><span class="nx">btn</span><span class="p">.</span><span class="nx">innerHTML</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">prevText</span><span class="p">;</span> + +<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="p">[</span><span class="nx">coordsRecord</span><span class="p">,</span><span class="w"> </span><span class="nx">massRecord</span><span class="p">,</span><span class="w"> </span><span class="nx">time</span><span class="p">.</span><span class="nx">slice</span><span class="p">(</span><span class="mf">0</span><span class="p">,</span><span class="w"> </span><span class="nx">tInd</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mf">1</span><span class="p">)];</span> +<span class="p">}</span> + + +<span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="p">[</span><span class="nx">coordsRecordR</span><span class="p">,</span><span class="w"> </span><span class="nx">_</span><span class="p">,</span><span class="w"> </span><span class="nx">tR</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">genNBodyResults</span><span class="p">(</span><span class="mf">256</span><span class="p">,</span><span class="mf">1</span><span class="p">,</span><span class="mf">1001</span><span class="p">);</span> +<span class="w"> </span><span class="c1">//console.log(coordsRecordR);</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">yearSec</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">365</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">24</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mf">3600</span><span class="p">;</span> + +<span class="w"> </span><span class="kd">function</span><span class="w"> </span><span class="nx">createFrame</span><span class="p">(</span><span class="nx">coordsR</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="o">!</span><span class="nx">coordsR</span><span class="w"> </span><span class="o">||</span><span class="w"> </span><span class="o">!</span><span class="nx">coordsR</span><span class="p">[</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">||</span><span class="w"> </span><span class="o">!</span><span class="nx">coordsR</span><span class="p">[</span><span class="mf">1</span><span class="p">])</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="p">[];</span> +<span class="w"> </span><span class="p">}</span> + +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">traceCentralStar</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="nx">coordsR</span><span class="p">[</span><span class="mf">0</span><span class="p">][</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">1.5e11</span><span class="p">],</span> +<span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="nx">coordsR</span><span class="p">[</span><span class="mf">1</span><span class="p">][</span><span class="mf">0</span><span class="p">]</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">1.5e11</span><span class="p">],</span> +<span class="w"> </span><span class="nx">mode</span><span class="o">:</span><span class="w"> </span><span class="s1">'markers'</span><span class="p">,</span> +<span class="w"> </span><span class="nx">type</span><span class="o">:</span><span class="w"> </span><span class="s1">'scatter'</span><span class="p">,</span> +<span class="w"> </span><span class="nx">name</span><span class="o">:</span><span class="w"> </span><span class="s1">'Central star'</span><span class="p">,</span> +<span class="w"> </span><span class="nx">marker</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">color</span><span class="o">:</span><span class="w"> </span><span class="s1">'gold'</span><span class="p">,</span><span class="w"> </span><span class="nx">symbol</span><span class="o">:</span><span class="w"> </span><span class="s1">'star'</span><span class="p">,</span><span class="w"> </span><span class="nx">size</span><span class="o">:</span><span class="w"> </span><span class="mf">10</span><span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="p">};</span> + +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">xCoords</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coordsR</span><span class="p">[</span><span class="mf">0</span><span class="p">].</span><span class="nx">slice</span><span class="p">(</span><span class="mf">1</span><span class="p">).</span><span class="nx">map</span><span class="p">(</span><span class="nx">x</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">x</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">1.5e11</span><span class="p">);</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">yCoords</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">coordsR</span><span class="p">[</span><span class="mf">1</span><span class="p">].</span><span class="nx">slice</span><span class="p">(</span><span class="mf">1</span><span class="p">).</span><span class="nx">map</span><span class="p">(</span><span class="nx">y</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">y</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mf">1.5e11</span><span class="p">);</span> + +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">traceOtherBodies</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="nx">xCoords</span><span class="p">,</span> +<span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="nx">yCoords</span><span class="p">,</span> +<span class="w"> </span><span class="nx">mode</span><span class="o">:</span><span class="w"> </span><span class="s1">'markers'</span><span class="p">,</span> +<span class="w"> </span><span class="nx">type</span><span class="o">:</span><span class="w"> </span><span class="s1">'scatter'</span><span class="p">,</span> +<span class="w"> </span><span class="nx">name</span><span class="o">:</span><span class="w"> </span><span class="s1">''</span><span class="p">,</span> +<span class="w"> </span><span class="nx">marker</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">color</span><span class="o">:</span><span class="w"> </span><span class="s1">'dodgerblue'</span><span class="p">,</span><span class="w"> </span><span class="nx">symbol</span><span class="o">:</span><span class="w"> </span><span class="s1">'circle'</span><span class="p">,</span><span class="w"> </span><span class="nx">size</span><span class="o">:</span><span class="w"> </span><span class="mf">2</span><span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="p">};</span> + +<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="p">[</span><span class="nx">traceCentralStar</span><span class="p">,</span><span class="w"> </span><span class="nx">traceOtherBodies</span><span class="p">];</span> +<span class="w"> </span><span class="p">}</span> + + +<span class="w"> </span><span class="kd">function</span><span class="w"> </span><span class="nx">createLayout</span><span class="p">(</span><span class="nx">i</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">title</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">text</span><span class="o">:</span><span class="w"> </span><span class="sb">`N-Body Problem: t = </span><span class="si">${</span><span class="nb">Number</span><span class="p">(</span><span class="nx">t</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="nx">yearSec</span><span class="p">).</span><span class="nx">toFixed</span><span class="p">(</span><span class="mf">3</span><span class="p">)</span><span class="si">}</span><span class="sb"> years`</span><span class="p">,</span> +<span class="w"> </span><span class="nx">x</span><span class="o">:</span><span class="w"> </span><span class="mf">0.03</span><span class="p">,</span> +<span class="w"> </span><span class="nx">y</span><span class="o">:</span><span class="w"> </span><span class="mf">0.97</span><span class="p">,</span> +<span class="w"> </span><span class="nx">xanchor</span><span class="o">:</span><span class="w"> </span><span class="s1">'left'</span><span class="p">,</span> +<span class="w"> </span><span class="nx">yanchor</span><span class="o">:</span><span class="w"> </span><span class="s1">'top'</span><span class="p">,</span> +<span class="w"> </span><span class="nx">font</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">size</span><span class="o">:</span><span class="w"> </span><span class="mf">14</span><span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="nx">xaxis</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">title</span><span class="o">:</span><span class="w"> </span><span class="s1">'x [AU]'</span><span class="p">,</span><span class="w"> </span><span class="nx">range</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="mf">2.1</span><span class="p">,</span><span class="w"> </span><span class="mf">2.1</span><span class="p">]</span><span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="nx">yaxis</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">title</span><span class="o">:</span><span class="w"> </span><span class="s1">'y [AU]'</span><span class="p">,</span><span class="w"> </span><span class="nx">range</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="mf">2.1</span><span class="p">,</span><span class="w"> </span><span class="mf">2.1</span><span class="p">],</span><span class="w"> </span><span class="nx">scaleanchor</span><span class="o">:</span><span class="w"> </span><span class="s1">'x'</span><span class="p">,</span><span class="w"> </span><span class="nx">scaleratio</span><span class="o">:</span><span class="w"> </span><span class="mf">1</span><span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="nx">showlegend</span><span class="o">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span> +<span class="w"> </span><span class="nx">margin</span><span class="o">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">l</span><span class="o">:</span><span class="w"> </span><span class="mf">60</span><span class="p">,</span><span class="w"> </span><span class="nx">r</span><span class="o">:</span><span class="w"> </span><span class="mf">40</span><span class="p">,</span><span class="w"> </span><span class="nx">t</span><span class="o">:</span><span class="w"> </span><span class="mf">40</span><span class="p">,</span><span class="w"> </span><span class="nx">b</span><span class="o">:</span><span class="w"> </span><span class="mf">40</span><span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="nx">width</span><span class="o">:</span><span class="w"> </span><span class="mf">800</span><span class="p">,</span> +<span class="w"> </span><span class="nx">height</span><span class="o">:</span><span class="w"> </span><span class="mf">800</span><span class="p">,</span> +<span class="w"> </span><span class="nx">plot_bgcolor</span><span class="o">:</span><span class="w"> </span><span class="s1">'black'</span><span class="p">,</span> +<span class="w"> </span><span class="p">};</span> +<span class="p">}</span> + +<span class="w"> </span><span class="kd">function</span><span class="w"> </span><span class="nx">animateNBodyProblem</span><span class="p">()</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">nFrames</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">tR</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> + +<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kd">let</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="nx">nFrames</span><span class="p">;</span><span class="w"> </span><span class="nx">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">frameData</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">createFrame</span><span class="p">(</span><span class="nx">coordsRecordR</span><span class="p">[</span><span class="nx">i</span><span class="p">]);</span> +<span class="w"> </span><span class="kd">const</span><span class="w"> </span><span class="nx">layout</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">createLayout</span><span class="p">(</span><span class="nx">i</span><span class="p">);</span> +<span class="w"> </span><span class="c1">//Plotly.newPlot(plotDiv, frameData, layout);</span> +<span class="w"> </span><span class="k">try</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">Plotly</span><span class="p">.</span><span class="nx">animate</span><span class="p">(</span><span class="s2">"plot"</span><span class="p">,</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">data</span><span class="o">:</span><span class="w"> </span><span class="nx">frameData</span><span class="p">,</span><span class="w"> </span><span class="nx">layout</span><span class="o">:</span><span class="w"> </span><span class="nx">layout</span> +<span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">staticPlot</span><span class="o">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span> +<span class="w"> </span><span class="nx">transition</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">duration</span><span class="o">:</span><span class="w"> </span><span class="mf">0</span><span class="p">,</span> +<span class="w"> </span><span class="p">},</span> +<span class="w"> </span><span class="nx">frame</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">duration</span><span class="o">:</span><span class="w"> </span><span class="mf">0</span><span class="p">,</span> +<span class="w"> </span><span class="nx">redraw</span><span class="o">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="p">});</span> +<span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">catch</span><span class="w"> </span><span class="p">(</span><span class="nx">err</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="nx">Plotly</span><span class="p">.</span><span class="nx">newPlot</span><span class="p">(</span><span class="s1">'plot'</span><span class="p">,</span><span class="w"> </span><span class="nx">frameData</span><span class="p">,</span><span class="w"> </span><span class="nx">layout</span><span class="p">);</span> +<span class="w"> </span><span class="p">}</span> +<span class="w"> </span><span class="p">}</span> +<span class="p">}</span> + +<span class="nx">animateNBodyProblem</span><span class="p">();</span> </code></pre> </div> <h2>Playground</h2> <script src="https://cdn.plot.ly/plotly-latest.min.js"></script> + <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjs/11.8.0/math.js"></script> + <script src="/assets/n-body/script.js"></script> + <div id="main-plot-div"> <noscript> The simulations require JavaScript to be viewed properly :( @@ -705,10 +710,12 @@ The simulations require JavaScript to be viewed properly :( <input type="number" min="1" max="10000" value="7e3" id="vRange"> </div> -<button type="button" id="startSim1" onclick="plotEarthSun()">Sun-Earth Orbit</button> + +<p><button type="button" id="startSim1" onclick="plotEarthSun()">Sun-Earth Orbit</button> <button type="button" id="startSim2" onclick="plotClassic3BodyProblem()">Classic 3-Body Problem</button> <button type="button" id="startSim3" onclick="plotRandomNBodySimulation()">Random n-Body Simulation</button> -<button type="button" id="startSim4" onclick="plotRandom3BodySimulation()">Random 3-Body Simulation</button> +<button type="button" id="startSim4" onclick="plotRandom3BodySimulation()">Random 3-Body Simulation</button></p> + <script> function clearAl() { plotOrbit = false; diff --git a/docs/posts/2023-10-04-bomb-lab.html b/docs/posts/2023-10-04-bomb-lab.html index 226487f..2c9518c 100644 --- a/docs/posts/2023-10-04-bomb-lab.html +++ b/docs/posts/2023-10-04-bomb-lab.html @@ -77,130 +77,133 @@ <h2>Phase 1</h2> <div class="codehilite"> -<pre><span></span><code>joxxxn@jupyter-nxxh6xx8:~/lab2-bomblab-navanchauhan/bombbomb$ gdb -ex <span class="s1">'break phase_1'</span> -ex <span class="s1">'break explode_bomb'</span> -ex <span class="s1">'run'</span> ./bomb -GNU gdb <span class="o">(</span>Ubuntu <span class="m">12</span>.1-0ubuntu1~22.04<span class="o">)</span> <span class="m">12</span>.1 -Copyright <span class="o">(</span>C<span class="o">)</span> <span class="m">2022</span> Free Software Foundation, Inc. -License GPLv3+: GNU GPL version <span class="m">3</span> or later <http://gnu.org/licenses/gpl.html> -This is free software: you are free to change and redistribute it. -There is NO WARRANTY, to the extent permitted by law. -Type <span class="s2">"show copying"</span> and <span class="s2">"show warranty"</span> <span class="k">for</span> details. -This GDB was configured as <span class="s2">"x86_64-linux-gnu"</span>. -Type <span class="s2">"show configuration"</span> <span class="k">for</span> configuration details. -For bug reporting instructions, please see: +<pre><span></span><code>joxxxn@jupyter-nxxh6xx8:~/lab2-bomblab-navanchauhan/bombbomb$<span class="w"> </span>gdb<span class="w"> </span>-ex<span class="w"> </span><span class="s1">'break phase_1'</span><span class="w"> </span>-ex<span class="w"> </span><span class="s1">'break explode_bomb'</span><span class="w"> </span>-ex<span class="w"> </span><span class="s1">'run'</span><span class="w"> </span>./bomb<span class="w"> </span> +GNU<span class="w"> </span>gdb<span class="w"> </span><span class="o">(</span>Ubuntu<span class="w"> </span><span class="m">12</span>.1-0ubuntu1~22.04<span class="o">)</span><span class="w"> </span><span class="m">12</span>.1 +Copyright<span class="w"> </span><span class="o">(</span>C<span class="o">)</span><span class="w"> </span><span class="m">2022</span><span class="w"> </span>Free<span class="w"> </span>Software<span class="w"> </span>Foundation,<span class="w"> </span>Inc. +License<span class="w"> </span>GPLv3+:<span class="w"> </span>GNU<span class="w"> </span>GPL<span class="w"> </span>version<span class="w"> </span><span class="m">3</span><span class="w"> </span>or<span class="w"> </span>later<span class="w"> </span><http://gnu.org/licenses/gpl.html> +This<span class="w"> </span>is<span class="w"> </span>free<span class="w"> </span>software:<span class="w"> </span>you<span class="w"> </span>are<span class="w"> </span>free<span class="w"> </span>to<span class="w"> </span>change<span class="w"> </span>and<span class="w"> </span>redistribute<span class="w"> </span>it. +There<span class="w"> </span>is<span class="w"> </span>NO<span class="w"> </span>WARRANTY,<span class="w"> </span>to<span class="w"> </span>the<span class="w"> </span>extent<span class="w"> </span>permitted<span class="w"> </span>by<span class="w"> </span>law. +Type<span class="w"> </span><span class="s2">"show copying"</span><span class="w"> </span>and<span class="w"> </span><span class="s2">"show warranty"</span><span class="w"> </span><span class="k">for</span><span class="w"> </span>details. +This<span class="w"> </span>GDB<span class="w"> </span>was<span class="w"> </span>configured<span class="w"> </span>as<span class="w"> </span><span class="s2">"x86_64-linux-gnu"</span>. +Type<span class="w"> </span><span class="s2">"show configuration"</span><span class="w"> </span><span class="k">for</span><span class="w"> </span>configuration<span class="w"> </span>details. +For<span class="w"> </span>bug<span class="w"> </span>reporting<span class="w"> </span>instructions,<span class="w"> </span>please<span class="w"> </span>see: <https://www.gnu.org/software/gdb/bugs/>. -Find the GDB manual and other documentation resources online at: - <http://www.gnu.org/software/gdb/documentation/>. - -For help, <span class="nb">type</span> <span class="s2">"help"</span>. -Type <span class="s2">"apropos word"</span> to search <span class="k">for</span> commands related to <span class="s2">"word"</span>... -Reading symbols from ./bomb... -Breakpoint <span class="m">1</span> at 0x15c7 -Breakpoint <span class="m">2</span> at 0x1d4a -Starting program: /home/joxxxn/lab2-bomblab-navanchauhan/bombbomb/bomb -<span class="o">[</span>Thread debugging using libthread_db enabled<span class="o">]</span> -Using host libthread_db library <span class="s2">"/lib/x86_64-linux-gnu/libthread_db.so.1"</span>. -Welcome to my fiendish little bomb. You have <span class="m">6</span> phases with -which to blow yourself up. Have a nice day! -<span class="nb">test</span> string - -Breakpoint <span class="m">1</span>, 0x00005555555555c7 <span class="k">in</span> phase_1 <span class="o">()</span> -<span class="o">(</span>gdb<span class="o">)</span> dias phase_1 -Undefined command: <span class="s2">"dias"</span>. Try <span class="s2">"help"</span>. -<span class="o">(</span>gdb<span class="o">)</span> disas phase_1 -Dump of assembler code <span class="k">for</span> <span class="k">function</span> phase_1: -<span class="o">=</span>> 0x00005555555555c7 <+0>: endbr64 - 0x00005555555555cb <+4>: sub <span class="nv">$0</span>x8,%rsp - 0x00005555555555cf <+8>: lea 0x1b7a<span class="o">(</span>%rip<span class="o">)</span>,%rsi <span class="c1"># 0x555555557150</span> - 0x00005555555555d6 <+15>: call 0x555555555b31 <strings_not_equal> - 0x00005555555555db <+20>: <span class="nb">test</span> %eax,%eax - 0x00005555555555dd <+22>: jne 0x5555555555e4 <phase_1+29> - 0x00005555555555df <+24>: add <span class="nv">$0</span>x8,%rsp - 0x00005555555555e3 <+28>: ret - 0x00005555555555e4 <+29>: call 0x555555555d4a <explode_bomb> - 0x00005555555555e9 <+34>: jmp 0x5555555555df <phase_1+24> -End of assembler dump. -<span class="o">(</span>gdb<span class="o">)</span> print 0x555555557150 -<span class="nv">$1</span> <span class="o">=</span> <span class="m">93824992244048</span> -<span class="o">(</span>gdb<span class="o">)</span> x/1s 0x555555557150 -0x555555557150: <span class="s2">"Controlling complexity is the essence of computer programming."</span> -<span class="o">(</span>gdb<span class="o">)</span> +Find<span class="w"> </span>the<span class="w"> </span>GDB<span class="w"> </span>manual<span class="w"> </span>and<span class="w"> </span>other<span class="w"> </span>documentation<span class="w"> </span>resources<span class="w"> </span>online<span class="w"> </span>at: +<span class="w"> </span><http://www.gnu.org/software/gdb/documentation/>. + +For<span class="w"> </span>help,<span class="w"> </span><span class="nb">type</span><span class="w"> </span><span class="s2">"help"</span>. +Type<span class="w"> </span><span class="s2">"apropos word"</span><span class="w"> </span>to<span class="w"> </span>search<span class="w"> </span><span class="k">for</span><span class="w"> </span>commands<span class="w"> </span>related<span class="w"> </span>to<span class="w"> </span><span class="s2">"word"</span>... +Reading<span class="w"> </span>symbols<span class="w"> </span>from<span class="w"> </span>./bomb... +Breakpoint<span class="w"> </span><span class="m">1</span><span class="w"> </span>at<span class="w"> </span>0x15c7 +Breakpoint<span class="w"> </span><span class="m">2</span><span class="w"> </span>at<span class="w"> </span>0x1d4a +Starting<span class="w"> </span>program:<span class="w"> </span>/home/joxxxn/lab2-bomblab-navanchauhan/bombbomb/bomb<span class="w"> </span> +<span class="o">[</span>Thread<span class="w"> </span>debugging<span class="w"> </span>using<span class="w"> </span>libthread_db<span class="w"> </span>enabled<span class="o">]</span> +Using<span class="w"> </span>host<span class="w"> </span>libthread_db<span class="w"> </span>library<span class="w"> </span><span class="s2">"/lib/x86_64-linux-gnu/libthread_db.so.1"</span>. +Welcome<span class="w"> </span>to<span class="w"> </span>my<span class="w"> </span>fiendish<span class="w"> </span>little<span class="w"> </span>bomb.<span class="w"> </span>You<span class="w"> </span>have<span class="w"> </span><span class="m">6</span><span class="w"> </span>phases<span class="w"> </span>with +which<span class="w"> </span>to<span class="w"> </span>blow<span class="w"> </span>yourself<span class="w"> </span>up.<span class="w"> </span>Have<span class="w"> </span>a<span class="w"> </span>nice<span class="w"> </span>day! +<span class="nb">test</span><span class="w"> </span>string + +Breakpoint<span class="w"> </span><span class="m">1</span>,<span class="w"> </span>0x00005555555555c7<span class="w"> </span><span class="k">in</span><span class="w"> </span>phase_1<span class="w"> </span><span class="o">()</span> +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span>dias<span class="w"> </span>phase_1 +Undefined<span class="w"> </span>command:<span class="w"> </span><span class="s2">"dias"</span>.<span class="w"> </span>Try<span class="w"> </span><span class="s2">"help"</span>. +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span>disas<span class="w"> </span>phase_1 +Dump<span class="w"> </span>of<span class="w"> </span>assembler<span class="w"> </span>code<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="k">function</span><span class="w"> </span>phase_1: +<span class="o">=</span>><span class="w"> </span>0x00005555555555c7<span class="w"> </span><+0>:<span class="w"> </span>endbr64<span class="w"> </span> +<span class="w"> </span>0x00005555555555cb<span class="w"> </span><+4>:<span class="w"> </span>sub<span class="w"> </span><span class="nv">$0</span>x8,%rsp +<span class="w"> </span>0x00005555555555cf<span class="w"> </span><+8>:<span class="w"> </span>lea<span class="w"> </span>0x1b7a<span class="o">(</span>%rip<span class="o">)</span>,%rsi<span class="w"> </span><span class="c1"># 0x555555557150</span> +<span class="w"> </span>0x00005555555555d6<span class="w"> </span><+15>:<span class="w"> </span>call<span class="w"> </span>0x555555555b31<span class="w"> </span><strings_not_equal> +<span class="w"> </span>0x00005555555555db<span class="w"> </span><+20>:<span class="w"> </span><span class="nb">test</span><span class="w"> </span>%eax,%eax +<span class="w"> </span>0x00005555555555dd<span class="w"> </span><+22>:<span class="w"> </span>jne<span class="w"> </span>0x5555555555e4<span class="w"> </span><phase_1+29> +<span class="w"> </span>0x00005555555555df<span class="w"> </span><+24>:<span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x8,%rsp +<span class="w"> </span>0x00005555555555e3<span class="w"> </span><+28>:<span class="w"> </span>ret<span class="w"> </span> +<span class="w"> </span>0x00005555555555e4<span class="w"> </span><+29>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span>0x00005555555555e9<span class="w"> </span><+34>:<span class="w"> </span>jmp<span class="w"> </span>0x5555555555df<span class="w"> </span><phase_1+24> +End<span class="w"> </span>of<span class="w"> </span>assembler<span class="w"> </span>dump. +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span>print<span class="w"> </span>0x555555557150 +<span class="nv">$1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="m">93824992244048</span> +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span>x/1s<span class="w"> </span>0x555555557150 +0x555555557150:<span class="w"> </span><span class="s2">"Controlling complexity is the essence of computer programming."</span> +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span> </code></pre> </div> <h2>Phase 2</h2> <div class="codehilite"> -<pre><span></span><code>Phase <span class="m">1</span> defused. How about the next one? -<span class="m">1</span> <span class="m">2</span> <span class="m">3</span> <span class="m">4</span> <span class="m">5</span> <span class="m">6</span> - -Breakpoint <span class="m">1</span>, 0x00005555555555eb <span class="k">in</span> phase_2 <span class="o">()</span> -<span class="o">(</span>gdb<span class="o">)</span> disas -Dump of assembler code <span class="k">for</span> <span class="k">function</span> phase_2: -<span class="o">=</span>> 0x00005555555555eb <+0>: endbr64 - 0x00005555555555ef <+4>: push %rbp - 0x00005555555555f0 <+5>: push %rbx - 0x00005555555555f1 <+6>: sub <span class="nv">$0</span>x28,%rsp - 0x00005555555555f5 <+10>: mov %rsp,%rsi - 0x00005555555555f8 <+13>: call 0x555555555d97 <read_six_numbers> - 0x00005555555555fd <+18>: cmpl <span class="nv">$0</span>x0,<span class="o">(</span>%rsp<span class="o">)</span> - 0x0000555555555601 <+22>: js 0x55555555560d <phase_2+34> - 0x0000555555555603 <+24>: mov %rsp,%rbp - 0x0000555555555606 <+27>: mov <span class="nv">$0</span>x1,%ebx - 0x000055555555560b <+32>: jmp 0x555555555620 <phase_2+53> - 0x000055555555560d <+34>: call 0x555555555d4a <explode_bomb> - 0x0000555555555612 <+39>: jmp 0x555555555603 <phase_2+24> - 0x0000555555555614 <+41>: add <span class="nv">$0</span>x1,%ebx - 0x0000555555555617 <+44>: add <span class="nv">$0</span>x4,%rbp - 0x000055555555561b <+48>: cmp <span class="nv">$0</span>x6,%ebx - 0x000055555555561e <+51>: je 0x555555555631 <phase_2+70> - 0x0000555555555620 <+53>: mov %ebx,%eax - 0x0000555555555622 <+55>: add 0x0<span class="o">(</span>%rbp<span class="o">)</span>,%eax - 0x0000555555555625 <+58>: cmp %eax,0x4<span class="o">(</span>%rbp<span class="o">)</span> - 0x0000555555555628 <+61>: je 0x555555555614 <phase_2+41> - 0x000055555555562a <+63>: call 0x555555555d4a <explode_bomb> - 0x000055555555562f <+68>: jmp 0x555555555614 <phase_2+41> - 0x0000555555555631 <+70>: add <span class="nv">$0</span>x28,%rsp - 0x0000555555555635 <+74>: pop %rbx - 0x0000555555555636 <+75>: pop %rbp - 0x0000555555555637 <+76>: ret -End of assembler dump. -<span class="o">(</span>gdb<span class="o">)</span> +<pre><span></span><code>Phase<span class="w"> </span><span class="m">1</span><span class="w"> </span>defused.<span class="w"> </span>How<span class="w"> </span>about<span class="w"> </span>the<span class="w"> </span>next<span class="w"> </span>one? +<span class="m">1</span><span class="w"> </span><span class="m">2</span><span class="w"> </span><span class="m">3</span><span class="w"> </span><span class="m">4</span><span class="w"> </span><span class="m">5</span><span class="w"> </span><span class="m">6</span> + +Breakpoint<span class="w"> </span><span class="m">1</span>,<span class="w"> </span>0x00005555555555eb<span class="w"> </span><span class="k">in</span><span class="w"> </span>phase_2<span class="w"> </span><span class="o">()</span> +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span>disas +Dump<span class="w"> </span>of<span class="w"> </span>assembler<span class="w"> </span>code<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="k">function</span><span class="w"> </span>phase_2: +<span class="o">=</span>><span class="w"> </span>0x00005555555555eb<span class="w"> </span><+0>:<span class="w"> </span>endbr64<span class="w"> </span> +<span class="w"> </span>0x00005555555555ef<span class="w"> </span><+4>:<span class="w"> </span>push<span class="w"> </span>%rbp +<span class="w"> </span>0x00005555555555f0<span class="w"> </span><+5>:<span class="w"> </span>push<span class="w"> </span>%rbx +<span class="w"> </span>0x00005555555555f1<span class="w"> </span><+6>:<span class="w"> </span>sub<span class="w"> </span><span class="nv">$0</span>x28,%rsp +<span class="w"> </span>0x00005555555555f5<span class="w"> </span><+10>:<span class="w"> </span>mov<span class="w"> </span>%rsp,%rsi +<span class="w"> </span>0x00005555555555f8<span class="w"> </span><+13>:<span class="w"> </span>call<span class="w"> </span>0x555555555d97<span class="w"> </span><read_six_numbers> +<span class="w"> </span>0x00005555555555fd<span class="w"> </span><+18>:<span class="w"> </span>cmpl<span class="w"> </span><span class="nv">$0</span>x0,<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>0x0000555555555601<span class="w"> </span><+22>:<span class="w"> </span>js<span class="w"> </span>0x55555555560d<span class="w"> </span><phase_2+34> +<span class="w"> </span>0x0000555555555603<span class="w"> </span><+24>:<span class="w"> </span>mov<span class="w"> </span>%rsp,%rbp +<span class="w"> </span>0x0000555555555606<span class="w"> </span><+27>:<span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x1,%ebx +<span class="w"> </span>0x000055555555560b<span class="w"> </span><+32>:<span class="w"> </span>jmp<span class="w"> </span>0x555555555620<span class="w"> </span><phase_2+53> +<span class="w"> </span>0x000055555555560d<span class="w"> </span><+34>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span>0x0000555555555612<span class="w"> </span><+39>:<span class="w"> </span>jmp<span class="w"> </span>0x555555555603<span class="w"> </span><phase_2+24> +<span class="w"> </span>0x0000555555555614<span class="w"> </span><+41>:<span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x1,%ebx +<span class="w"> </span>0x0000555555555617<span class="w"> </span><+44>:<span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x4,%rbp +<span class="w"> </span>0x000055555555561b<span class="w"> </span><+48>:<span class="w"> </span>cmp<span class="w"> </span><span class="nv">$0</span>x6,%ebx +<span class="w"> </span>0x000055555555561e<span class="w"> </span><+51>:<span class="w"> </span>je<span class="w"> </span>0x555555555631<span class="w"> </span><phase_2+70> +<span class="w"> </span>0x0000555555555620<span class="w"> </span><+53>:<span class="w"> </span>mov<span class="w"> </span>%ebx,%eax +<span class="w"> </span>0x0000555555555622<span class="w"> </span><+55>:<span class="w"> </span>add<span class="w"> </span>0x0<span class="o">(</span>%rbp<span class="o">)</span>,%eax +<span class="w"> </span>0x0000555555555625<span class="w"> </span><+58>:<span class="w"> </span>cmp<span class="w"> </span>%eax,0x4<span class="o">(</span>%rbp<span class="o">)</span> +<span class="w"> </span>0x0000555555555628<span class="w"> </span><+61>:<span class="w"> </span>je<span class="w"> </span>0x555555555614<span class="w"> </span><phase_2+41> +<span class="w"> </span>0x000055555555562a<span class="w"> </span><+63>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span>0x000055555555562f<span class="w"> </span><+68>:<span class="w"> </span>jmp<span class="w"> </span>0x555555555614<span class="w"> </span><phase_2+41> +<span class="w"> </span>0x0000555555555631<span class="w"> </span><+70>:<span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x28,%rsp +<span class="w"> </span>0x0000555555555635<span class="w"> </span><+74>:<span class="w"> </span>pop<span class="w"> </span>%rbx +<span class="w"> </span>0x0000555555555636<span class="w"> </span><+75>:<span class="w"> </span>pop<span class="w"> </span>%rbp +<span class="w"> </span>0x0000555555555637<span class="w"> </span><+76>:<span class="w"> </span>ret<span class="w"> </span> +End<span class="w"> </span>of<span class="w"> </span>assembler<span class="w"> </span>dump. +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span> </code></pre> </div> <div class="codehilite"> -<pre><span></span><code> 0x00005555555555fd <+18>: cmpl <span class="nv">$0</span>x0,<span class="o">(</span>%rsp<span class="o">)</span> - 0x0000555555555601 <+22>: js 0x55555555560d <phase_2+34> +<pre><span></span><code><span class="w"> </span>0x00005555555555fd<span class="w"> </span><+18>:<span class="w"> </span>cmpl<span class="w"> </span><span class="nv">$0</span>x0,<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>0x0000555555555601<span class="w"> </span><+22>:<span class="w"> </span>js<span class="w"> </span>0x55555555560d<span class="w"> </span><phase_2+34> ... - 0x000055555555560d <+34>: call 0x555555555d4a <explode_bomb> +<span class="w"> </span>0x000055555555560d<span class="w"> </span><+34>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> </code></pre> </div> -<p>The program first compares if the first number is not 0. If the number is not 0, then the <code>cmpl</code> instruction returns a negative value. The <code>js</code> instruction stands for jump if sign -> causing a jump to the specified address if the sign bit is set. This would result in the explode_bomb function being called. - <div class="codehilite"> - <pre><span></span><code>0x0000555555555603 <+24>: mov %rsp,%rbp - 0x0000555555555606 <+27>: mov <span class="nv">$0</span>x1,%ebx - </code></pre> - </div></p> +<p>The program first compares if the first number is not 0. If the number is not 0, then the <code>cmpl</code> instruction returns a negative value. The <code>js</code> instruction stands for jump if sign -> causing a jump to the specified address if the sign bit is set. This would result in the explode_bomb function being called.</p> + +<div class="codehilite"> +<pre><span></span><code><span class="w"> </span>0x0000555555555603<span class="w"> </span><+24>:<span class="w"> </span>mov<span class="w"> </span>%rsp,%rbp +<span class="w"> </span>0x0000555555555606<span class="w"> </span><+27>:<span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x1,%ebx +</code></pre> +</div> <p><code>%rsp</code> in x86-64 asm, is the stack pointer i.e. it points to the top of the current stack frame. Since the program just read six numbers, the top of the stack (<code>%rsp</code>) contains the address of the first number.</p> <p>By executing <code>mov %rsp,%rbp</code> we are setting the base pointer (<code>%rbp</code>) to point to this address.</p> -<p>Now, for the second instruction <code>mov $0x1,%ebx</code>, we are initalising the <code>%ebx</code> register with the value 1. Based on the assembly code, you can see that this is being used as a counter/index for the loop. - <div class="codehilite"> - <pre><span></span><code>0x000055555555560b <+32>: jmp 0x555555555620 <phase_2+53> - </code></pre> - </div></p> - -<p>The program now jumps to <phase_2+53> - <div class="codehilite"> - <pre><span></span><code>0x0000555555555620 <+53>: mov %ebx,%eax - 0x0000555555555622 <+55>: add 0x0<span class="o">(</span>%rbp<span class="o">)</span>,%eax - 0x0000555555555625 <+58>: cmp %eax,0x4<span class="o">(</span>%rbp<span class="o">)</span> - 0x0000555555555628 <+61>: je 0x555555555614 <phase_2+41> - </code></pre> - </div></p> +<p>Now, for the second instruction <code>mov $0x1,%ebx</code>, we are initalising the <code>%ebx</code> register with the value 1. Based on the assembly code, you can see that this is being used as a counter/index for the loop.</p> + +<div class="codehilite"> +<pre><span></span><code><span class="w"> </span>0x000055555555560b<span class="w"> </span><+32>:<span class="w"> </span>jmp<span class="w"> </span>0x555555555620<span class="w"> </span><phase_2+53> +</code></pre> +</div> + +<p>The program now jumps to <phase_2+53></p> + +<div class="codehilite"> +<pre><span></span><code><span class="w"> </span>0x0000555555555620<span class="w"> </span><+53>:<span class="w"> </span>mov<span class="w"> </span>%ebx,%eax +<span class="w"> </span>0x0000555555555622<span class="w"> </span><+55>:<span class="w"> </span>add<span class="w"> </span>0x0<span class="o">(</span>%rbp<span class="o">)</span>,%eax +<span class="w"> </span>0x0000555555555625<span class="w"> </span><+58>:<span class="w"> </span>cmp<span class="w"> </span>%eax,0x4<span class="o">(</span>%rbp<span class="o">)</span> +<span class="w"> </span>0x0000555555555628<span class="w"> </span><+61>:<span class="w"> </span>je<span class="w"> </span>0x555555555614<span class="w"> </span><phase_2+41> +</code></pre> +</div> <p>Here, the value from <code>%ebx</code> is copied to the <code>%eax</code> register. For this iteration, the value should be 1.</p> @@ -208,18 +211,19 @@ End of assembler dump. <p><code>cmp %eax,0x4(%rbp)</code> - The instruction compares the value in %eax to the value at the memory address <code>%rbp + 4</code>. Since Integers in this context are stored using a word of memory of 4 bytes, this indicates it checks against the second number in the sequence.</p> -<p><code>je 0x555555555614 <phase_2+41></code> - The program will jump to <code>phase_2+41</code> if the previous <code>cmp</code> instruction determined the values as equal. - <div class="codehilite"> - <pre><span></span><code>0x0000555555555614 <+41>: add <span class="nv">$0</span>x1,%ebx - 0x0000555555555617 <+44>: add <span class="nv">$0</span>x4,%rbp - 0x000055555555561b <+48>: cmp <span class="nv">$0</span>x6,%ebx - 0x000055555555561e <+51>: je 0x555555555631 <phase<em>2+70> - 0x0000555555555620 <+53>: mov %ebx,%eax - 0x0000555555555622 <+55>: add 0x0<span class="o">(</span>%rbp<span class="o">)</span>,%eax - 0x0000555555555625 <+58>: cmp %eax,0x4<span class="o">(</span>%rbp<span class="o">)</span> - 0x0000555555555628 <+61>: je 0x555555555614 <phase</em>2+41> - </code></pre> - </div></p> +<p><code>je 0x555555555614 <phase_2+41></code> - The program will jump to <code>phase_2+41</code> if the previous <code>cmp</code> instruction determined the values as equal. </p> + +<div class="codehilite"> +<pre><span></span><code><span class="w"> </span>0x0000555555555614<span class="w"> </span><+41>:<span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x1,%ebx +<span class="w"> </span>0x0000555555555617<span class="w"> </span><+44>:<span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x4,%rbp +<span class="w"> </span>0x000055555555561b<span class="w"> </span><+48>:<span class="w"> </span>cmp<span class="w"> </span><span class="nv">$0</span>x6,%ebx +<span class="w"> </span>0x000055555555561e<span class="w"> </span><+51>:<span class="w"> </span>je<span class="w"> </span>0x555555555631<span class="w"> </span><phase_2+70> +<span class="w"> </span>0x0000555555555620<span class="w"> </span><+53>:<span class="w"> </span>mov<span class="w"> </span>%ebx,%eax +<span class="w"> </span>0x0000555555555622<span class="w"> </span><+55>:<span class="w"> </span>add<span class="w"> </span>0x0<span class="o">(</span>%rbp<span class="o">)</span>,%eax +<span class="w"> </span>0x0000555555555625<span class="w"> </span><+58>:<span class="w"> </span>cmp<span class="w"> </span>%eax,0x4<span class="o">(</span>%rbp<span class="o">)</span> +<span class="w"> </span>0x0000555555555628<span class="w"> </span><+61>:<span class="w"> </span>je<span class="w"> </span>0x555555555614<span class="w"> </span><phase_2+41> +</code></pre> +</div> <p>Here, we can see that the program increments <code>%ebx</code> by 1, adds a 4 byte offset to <code>%rbp</code> (the number we will be matching now), and checks if <code>%ebx</code> is equal to 6. If it is, it breaks the loop and jumps to <code><phase_2+70></code> succesfully finishing this stage.</p> @@ -236,13 +240,13 @@ End of assembler dump. <div class="codehilite"> <pre><span></span><code>... -Phase <span class="m">1</span> defused. How about the next one? -<span class="m">0</span> <span class="m">1</span> <span class="m">3</span> <span class="m">6</span> <span class="m">10</span> <span class="m">15</span> +Phase<span class="w"> </span><span class="m">1</span><span class="w"> </span>defused.<span class="w"> </span>How<span class="w"> </span>about<span class="w"> </span>the<span class="w"> </span>next<span class="w"> </span>one? +<span class="m">0</span><span class="w"> </span><span class="m">1</span><span class="w"> </span><span class="m">3</span><span class="w"> </span><span class="m">6</span><span class="w"> </span><span class="m">10</span><span class="w"> </span><span class="m">15</span> -Breakpoint <span class="m">1</span>, 0x00005555555555eb <span class="k">in</span> phase_2 <span class="o">()</span> -<span class="o">(</span>gdb<span class="o">)</span> <span class="k">continue</span> +Breakpoint<span class="w"> </span><span class="m">1</span>,<span class="w"> </span>0x00005555555555eb<span class="w"> </span><span class="k">in</span><span class="w"> </span>phase_2<span class="w"> </span><span class="o">()</span> +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span><span class="k">continue</span> Continuing. -That<span class="err">'</span>s number <span class="m">2</span>. Keep going! +That<span class="err">'</span>s<span class="w"> </span>number<span class="w"> </span><span class="m">2</span>.<span class="w"> </span>Keep<span class="w"> </span>going! </code></pre> </div> @@ -251,96 +255,96 @@ That<span class="err">'</span>s number <span class="m">2</span>. Keep going <p>Let us look at the disassembled code first</p> <div class="codehilite"> -<pre><span></span><code><span class="m">0000000000001638</span> <phase_3>: - <span class="m">1638</span>: f3 0f 1e fa endbr64 - 163c: <span class="m">48</span> <span class="m">83</span> ec <span class="m">18</span> sub <span class="nv">$0</span>x18,%rsp - <span class="m">1640</span>: <span class="m">48</span> 8d 4c <span class="m">24</span> <span class="m">07</span> lea 0x7<span class="o">(</span>%rsp<span class="o">)</span>,%rcx - <span class="m">1645</span>: <span class="m">48</span> 8d <span class="m">54</span> <span class="m">24</span> 0c lea 0xc<span class="o">(</span>%rsp<span class="o">)</span>,%rdx - 164a: 4c 8d <span class="m">44</span> <span class="m">24</span> <span class="m">08</span> lea 0x8<span class="o">(</span>%rsp<span class="o">)</span>,%r8 - 164f: <span class="m">48</span> 8d <span class="m">35</span> <span class="m">60</span> 1b <span class="m">00</span> <span class="m">00</span> lea 0x1b60<span class="o">(</span>%rip<span class="o">)</span>,%rsi <span class="c1"># 31b6 <_IO_stdin_used+0x1b6></span> - <span class="m">1656</span>: b8 <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> mov <span class="nv">$0</span>x0,%eax - 165b: e8 <span class="m">80</span> <span class="nb">fc</span> ff ff call 12e0 <__isoc99_sscanf@plt> - <span class="m">1660</span>: <span class="m">83</span> f8 <span class="m">02</span> cmp <span class="nv">$0</span>x2,%eax - <span class="m">1663</span>: 7e <span class="m">20</span> jle <span class="m">1685</span> <phase_3+0x4d> - <span class="m">1665</span>: <span class="m">83</span> 7c <span class="m">24</span> 0c <span class="m">07</span> cmpl <span class="nv">$0</span>x7,0xc<span class="o">(</span>%rsp<span class="o">)</span> - 166a: 0f <span class="m">87</span> 0d <span class="m">01</span> <span class="m">00</span> <span class="m">00</span> ja 177d <phase_3+0x145> - <span class="m">1670</span>: 8b <span class="m">44</span> <span class="m">24</span> 0c mov 0xc<span class="o">(</span>%rsp<span class="o">)</span>,%eax - <span class="m">1674</span>: <span class="m">48</span> 8d <span class="m">15</span> <span class="m">55</span> 1b <span class="m">00</span> <span class="m">00</span> lea 0x1b55<span class="o">(</span>%rip<span class="o">)</span>,%rdx <span class="c1"># 31d0 <_IO_stdin_used+0x1d0></span> - 167b: <span class="m">48</span> <span class="m">63</span> <span class="m">04</span> <span class="m">82</span> movslq <span class="o">(</span>%rdx,%rax,4<span class="o">)</span>,%rax - 167f: <span class="m">48</span> <span class="m">01</span> d0 add %rdx,%rax - <span class="m">1682</span>: 3e ff e0 notrack jmp *%rax - <span class="m">1685</span>: e8 c0 <span class="m">06</span> <span class="m">00</span> <span class="m">00</span> call 1d4a <explode_bomb> - 168a: eb d9 jmp <span class="m">1665</span> <phase_3+0x2d> - 168c: b8 <span class="m">63</span> <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> mov <span class="nv">$0</span>x63,%eax - <span class="m">1691</span>: <span class="m">81</span> 7c <span class="m">24</span> <span class="m">08</span> 3d <span class="m">02</span> <span class="m">00</span> cmpl <span class="nv">$0</span>x23d,0x8<span class="o">(</span>%rsp<span class="o">)</span> - <span class="m">1698</span>: <span class="m">00</span> - <span class="m">1699</span>: 0f <span class="m">84</span> e8 <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> je <span class="m">1787</span> <phase_3+0x14f> - 169f: e8 a6 <span class="m">06</span> <span class="m">00</span> <span class="m">00</span> call 1d4a <explode_bomb> - 16a4: b8 <span class="m">63</span> <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> mov <span class="nv">$0</span>x63,%eax - 16a9: e9 d9 <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> jmp <span class="m">1787</span> <phase_3+0x14f> - 16ae: b8 <span class="m">61</span> <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> mov <span class="nv">$0</span>x61,%eax - 16b3: <span class="m">81</span> 7c <span class="m">24</span> <span class="m">08</span> <span class="m">27</span> <span class="m">01</span> <span class="m">00</span> cmpl <span class="nv">$0</span>x127,0x8<span class="o">(</span>%rsp<span class="o">)</span> - 16ba: <span class="m">00</span> - 16bb: 0f <span class="m">84</span> c6 <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> je <span class="m">1787</span> <phase_3+0x14f> - 16c1: e8 <span class="m">84</span> <span class="m">06</span> <span class="m">00</span> <span class="m">00</span> call 1d4a <explode_bomb> - 16c6: b8 <span class="m">61</span> <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> mov <span class="nv">$0</span>x61,%eax - 16cb: e9 b7 <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> jmp <span class="m">1787</span> <phase_3+0x14f> - 16d0: b8 <span class="m">78</span> <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> mov <span class="nv">$0</span>x78,%eax - 16d5: <span class="m">81</span> 7c <span class="m">24</span> <span class="m">08</span> e7 <span class="m">02</span> <span class="m">00</span> cmpl <span class="nv">$0</span>x2e7,0x8<span class="o">(</span>%rsp<span class="o">)</span> - 16dc: <span class="m">00</span> - 16dd: 0f <span class="m">84</span> a4 <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> je <span class="m">1787</span> <phase_3+0x14f> - 16e3: e8 <span class="m">62</span> <span class="m">06</span> <span class="m">00</span> <span class="m">00</span> call 1d4a <explode_bomb> - 16e8: b8 <span class="m">78</span> <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> mov <span class="nv">$0</span>x78,%eax - 16ed: e9 <span class="m">95</span> <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> jmp <span class="m">1787</span> <phase_3+0x14f> - 16f2: b8 <span class="m">64</span> <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> mov <span class="nv">$0</span>x64,%eax - 16f7: <span class="m">81</span> 7c <span class="m">24</span> <span class="m">08</span> <span class="m">80</span> <span class="m">02</span> <span class="m">00</span> cmpl <span class="nv">$0</span>x280,0x8<span class="o">(</span>%rsp<span class="o">)</span> - 16fe: <span class="m">00</span> - 16ff: 0f <span class="m">84</span> <span class="m">82</span> <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> je <span class="m">1787</span> <phase_3+0x14f> - <span class="m">1705</span>: e8 <span class="m">40</span> <span class="m">06</span> <span class="m">00</span> <span class="m">00</span> call 1d4a <explode_bomb> - 170a: b8 <span class="m">64</span> <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> mov <span class="nv">$0</span>x64,%eax - 170f: eb <span class="m">76</span> jmp <span class="m">1787</span> <phase_3+0x14f> - <span class="m">1711</span>: b8 6d <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> mov <span class="nv">$0</span>x6d,%eax - <span class="m">1716</span>: <span class="m">81</span> 7c <span class="m">24</span> <span class="m">08</span> ff <span class="m">02</span> <span class="m">00</span> cmpl <span class="nv">$0</span>x2ff,0x8<span class="o">(</span>%rsp<span class="o">)</span> - 171d: <span class="m">00</span> - 171e: <span class="m">74</span> <span class="m">67</span> je <span class="m">1787</span> <phase_3+0x14f> - <span class="m">1720</span>: e8 <span class="m">25</span> <span class="m">06</span> <span class="m">00</span> <span class="m">00</span> call 1d4a <explode_bomb> - <span class="m">1725</span>: b8 6d <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> mov <span class="nv">$0</span>x6d,%eax - 172a: eb 5b jmp <span class="m">1787</span> <phase_3+0x14f> - 172c: b8 <span class="m">71</span> <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> mov <span class="nv">$0</span>x71,%eax - <span class="m">1731</span>: <span class="m">81</span> 7c <span class="m">24</span> <span class="m">08</span> <span class="m">75</span> <span class="m">03</span> <span class="m">00</span> cmpl <span class="nv">$0</span>x375,0x8<span class="o">(</span>%rsp<span class="o">)</span> - <span class="m">1738</span>: <span class="m">00</span> - <span class="m">1739</span>: <span class="m">74</span> 4c je <span class="m">1787</span> <phase_3+0x14f> - 173b: e8 0a <span class="m">06</span> <span class="m">00</span> <span class="m">00</span> call 1d4a <explode_bomb> - <span class="m">1740</span>: b8 <span class="m">71</span> <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> mov <span class="nv">$0</span>x71,%eax - <span class="m">1745</span>: eb <span class="m">40</span> jmp <span class="m">1787</span> <phase_3+0x14f> - <span class="m">1747</span>: b8 <span class="m">79</span> <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> mov <span class="nv">$0</span>x79,%eax - 174c: <span class="m">81</span> 7c <span class="m">24</span> <span class="m">08</span> <span class="m">94</span> <span class="m">02</span> <span class="m">00</span> cmpl <span class="nv">$0</span>x294,0x8<span class="o">(</span>%rsp<span class="o">)</span> - <span class="m">1753</span>: <span class="m">00</span> - <span class="m">1754</span>: <span class="m">74</span> <span class="m">31</span> je <span class="m">1787</span> <phase_3+0x14f> - <span class="m">1756</span>: e8 ef <span class="m">05</span> <span class="m">00</span> <span class="m">00</span> call 1d4a <explode_bomb> - 175b: b8 <span class="m">79</span> <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> mov <span class="nv">$0</span>x79,%eax - <span class="m">1760</span>: eb <span class="m">25</span> jmp <span class="m">1787</span> <phase_3+0x14f> - <span class="m">1762</span>: b8 <span class="m">79</span> <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> mov <span class="nv">$0</span>x79,%eax - <span class="m">1767</span>: <span class="m">81</span> 7c <span class="m">24</span> <span class="m">08</span> <span class="m">88</span> <span class="m">02</span> <span class="m">00</span> cmpl <span class="nv">$0</span>x288,0x8<span class="o">(</span>%rsp<span class="o">)</span> - 176e: <span class="m">00</span> - 176f: <span class="m">74</span> <span class="m">16</span> je <span class="m">1787</span> <phase_3+0x14f> - <span class="m">1771</span>: e8 d4 <span class="m">05</span> <span class="m">00</span> <span class="m">00</span> call 1d4a <explode_bomb> - <span class="m">1776</span>: b8 <span class="m">79</span> <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> mov <span class="nv">$0</span>x79,%eax - 177b: eb 0a jmp <span class="m">1787</span> <phase_3+0x14f> - 177d: e8 c8 <span class="m">05</span> <span class="m">00</span> <span class="m">00</span> call 1d4a <explode_bomb> - <span class="m">1782</span>: b8 <span class="m">68</span> <span class="m">00</span> <span class="m">00</span> <span class="m">00</span> mov <span class="nv">$0</span>x68,%eax - <span class="m">1787</span>: <span class="m">38</span> <span class="m">44</span> <span class="m">24</span> <span class="m">07</span> cmp %al,0x7<span class="o">(</span>%rsp<span class="o">)</span> - 178b: <span class="m">75</span> <span class="m">05</span> jne <span class="m">1792</span> <phase_3+0x15a> - 178d: <span class="m">48</span> <span class="m">83</span> c4 <span class="m">18</span> add <span class="nv">$0</span>x18,%rsp - <span class="m">1791</span>: c3 ret - <span class="m">1792</span>: e8 b3 <span class="m">05</span> <span class="m">00</span> <span class="m">00</span> call 1d4a <explode_bomb> - <span class="m">1797</span>: eb f4 jmp 178d <phase_3+0x155> +<pre><span></span><code><span class="m">0000000000001638</span><span class="w"> </span><phase_3>: +<span class="w"> </span><span class="m">1638</span>:<span class="w"> </span>f3<span class="w"> </span>0f<span class="w"> </span>1e<span class="w"> </span>fa<span class="w"> </span>endbr64<span class="w"> </span> +<span class="w"> </span>163c:<span class="w"> </span><span class="m">48</span><span class="w"> </span><span class="m">83</span><span class="w"> </span>ec<span class="w"> </span><span class="m">18</span><span class="w"> </span>sub<span class="w"> </span><span class="nv">$0</span>x18,%rsp +<span class="w"> </span><span class="m">1640</span>:<span class="w"> </span><span class="m">48</span><span class="w"> </span>8d<span class="w"> </span>4c<span class="w"> </span><span class="m">24</span><span class="w"> </span><span class="m">07</span><span class="w"> </span>lea<span class="w"> </span>0x7<span class="o">(</span>%rsp<span class="o">)</span>,%rcx +<span class="w"> </span><span class="m">1645</span>:<span class="w"> </span><span class="m">48</span><span class="w"> </span>8d<span class="w"> </span><span class="m">54</span><span class="w"> </span><span class="m">24</span><span class="w"> </span>0c<span class="w"> </span>lea<span class="w"> </span>0xc<span class="o">(</span>%rsp<span class="o">)</span>,%rdx +<span class="w"> </span>164a:<span class="w"> </span>4c<span class="w"> </span>8d<span class="w"> </span><span class="m">44</span><span class="w"> </span><span class="m">24</span><span class="w"> </span><span class="m">08</span><span class="w"> </span>lea<span class="w"> </span>0x8<span class="o">(</span>%rsp<span class="o">)</span>,%r8 +<span class="w"> </span>164f:<span class="w"> </span><span class="m">48</span><span class="w"> </span>8d<span class="w"> </span><span class="m">35</span><span class="w"> </span><span class="m">60</span><span class="w"> </span>1b<span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>lea<span class="w"> </span>0x1b60<span class="o">(</span>%rip<span class="o">)</span>,%rsi<span class="w"> </span><span class="c1"># 31b6 <_IO_stdin_used+0x1b6></span> +<span class="w"> </span><span class="m">1656</span>:<span class="w"> </span>b8<span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x0,%eax +<span class="w"> </span>165b:<span class="w"> </span>e8<span class="w"> </span><span class="m">80</span><span class="w"> </span><span class="nb">fc</span><span class="w"> </span>ff<span class="w"> </span>ff<span class="w"> </span>call<span class="w"> </span>12e0<span class="w"> </span><__isoc99_sscanf@plt> +<span class="w"> </span><span class="m">1660</span>:<span class="w"> </span><span class="m">83</span><span class="w"> </span>f8<span class="w"> </span><span class="m">02</span><span class="w"> </span>cmp<span class="w"> </span><span class="nv">$0</span>x2,%eax +<span class="w"> </span><span class="m">1663</span>:<span class="w"> </span>7e<span class="w"> </span><span class="m">20</span><span class="w"> </span>jle<span class="w"> </span><span class="m">1685</span><span class="w"> </span><phase_3+0x4d> +<span class="w"> </span><span class="m">1665</span>:<span class="w"> </span><span class="m">83</span><span class="w"> </span>7c<span class="w"> </span><span class="m">24</span><span class="w"> </span>0c<span class="w"> </span><span class="m">07</span><span class="w"> </span>cmpl<span class="w"> </span><span class="nv">$0</span>x7,0xc<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>166a:<span class="w"> </span>0f<span class="w"> </span><span class="m">87</span><span class="w"> </span>0d<span class="w"> </span><span class="m">01</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>ja<span class="w"> </span>177d<span class="w"> </span><phase_3+0x145> +<span class="w"> </span><span class="m">1670</span>:<span class="w"> </span>8b<span class="w"> </span><span class="m">44</span><span class="w"> </span><span class="m">24</span><span class="w"> </span>0c<span class="w"> </span>mov<span class="w"> </span>0xc<span class="o">(</span>%rsp<span class="o">)</span>,%eax +<span class="w"> </span><span class="m">1674</span>:<span class="w"> </span><span class="m">48</span><span class="w"> </span>8d<span class="w"> </span><span class="m">15</span><span class="w"> </span><span class="m">55</span><span class="w"> </span>1b<span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>lea<span class="w"> </span>0x1b55<span class="o">(</span>%rip<span class="o">)</span>,%rdx<span class="w"> </span><span class="c1"># 31d0 <_IO_stdin_used+0x1d0></span> +<span class="w"> </span>167b:<span class="w"> </span><span class="m">48</span><span class="w"> </span><span class="m">63</span><span class="w"> </span><span class="m">04</span><span class="w"> </span><span class="m">82</span><span class="w"> </span>movslq<span class="w"> </span><span class="o">(</span>%rdx,%rax,4<span class="o">)</span>,%rax +<span class="w"> </span>167f:<span class="w"> </span><span class="m">48</span><span class="w"> </span><span class="m">01</span><span class="w"> </span>d0<span class="w"> </span>add<span class="w"> </span>%rdx,%rax +<span class="w"> </span><span class="m">1682</span>:<span class="w"> </span>3e<span class="w"> </span>ff<span class="w"> </span>e0<span class="w"> </span>notrack<span class="w"> </span>jmp<span class="w"> </span>*%rax +<span class="w"> </span><span class="m">1685</span>:<span class="w"> </span>e8<span class="w"> </span>c0<span class="w"> </span><span class="m">06</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>call<span class="w"> </span>1d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span>168a:<span class="w"> </span>eb<span class="w"> </span>d9<span class="w"> </span>jmp<span class="w"> </span><span class="m">1665</span><span class="w"> </span><phase_3+0x2d> +<span class="w"> </span>168c:<span class="w"> </span>b8<span class="w"> </span><span class="m">63</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x63,%eax +<span class="w"> </span><span class="m">1691</span>:<span class="w"> </span><span class="m">81</span><span class="w"> </span>7c<span class="w"> </span><span class="m">24</span><span class="w"> </span><span class="m">08</span><span class="w"> </span>3d<span class="w"> </span><span class="m">02</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>cmpl<span class="w"> </span><span class="nv">$0</span>x23d,0x8<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span><span class="m">1698</span>:<span class="w"> </span><span class="m">00</span><span class="w"> </span> +<span class="w"> </span><span class="m">1699</span>:<span class="w"> </span>0f<span class="w"> </span><span class="m">84</span><span class="w"> </span>e8<span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>je<span class="w"> </span><span class="m">1787</span><span class="w"> </span><phase_3+0x14f> +<span class="w"> </span>169f:<span class="w"> </span>e8<span class="w"> </span>a6<span class="w"> </span><span class="m">06</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>call<span class="w"> </span>1d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span>16a4:<span class="w"> </span>b8<span class="w"> </span><span class="m">63</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x63,%eax +<span class="w"> </span>16a9:<span class="w"> </span>e9<span class="w"> </span>d9<span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>jmp<span class="w"> </span><span class="m">1787</span><span class="w"> </span><phase_3+0x14f> +<span class="w"> </span>16ae:<span class="w"> </span>b8<span class="w"> </span><span class="m">61</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x61,%eax +<span class="w"> </span>16b3:<span class="w"> </span><span class="m">81</span><span class="w"> </span>7c<span class="w"> </span><span class="m">24</span><span class="w"> </span><span class="m">08</span><span class="w"> </span><span class="m">27</span><span class="w"> </span><span class="m">01</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>cmpl<span class="w"> </span><span class="nv">$0</span>x127,0x8<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>16ba:<span class="w"> </span><span class="m">00</span><span class="w"> </span> +<span class="w"> </span>16bb:<span class="w"> </span>0f<span class="w"> </span><span class="m">84</span><span class="w"> </span>c6<span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>je<span class="w"> </span><span class="m">1787</span><span class="w"> </span><phase_3+0x14f> +<span class="w"> </span>16c1:<span class="w"> </span>e8<span class="w"> </span><span class="m">84</span><span class="w"> </span><span class="m">06</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>call<span class="w"> </span>1d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span>16c6:<span class="w"> </span>b8<span class="w"> </span><span class="m">61</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x61,%eax +<span class="w"> </span>16cb:<span class="w"> </span>e9<span class="w"> </span>b7<span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>jmp<span class="w"> </span><span class="m">1787</span><span class="w"> </span><phase_3+0x14f> +<span class="w"> </span>16d0:<span class="w"> </span>b8<span class="w"> </span><span class="m">78</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x78,%eax +<span class="w"> </span>16d5:<span class="w"> </span><span class="m">81</span><span class="w"> </span>7c<span class="w"> </span><span class="m">24</span><span class="w"> </span><span class="m">08</span><span class="w"> </span>e7<span class="w"> </span><span class="m">02</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>cmpl<span class="w"> </span><span class="nv">$0</span>x2e7,0x8<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>16dc:<span class="w"> </span><span class="m">00</span><span class="w"> </span> +<span class="w"> </span>16dd:<span class="w"> </span>0f<span class="w"> </span><span class="m">84</span><span class="w"> </span>a4<span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>je<span class="w"> </span><span class="m">1787</span><span class="w"> </span><phase_3+0x14f> +<span class="w"> </span>16e3:<span class="w"> </span>e8<span class="w"> </span><span class="m">62</span><span class="w"> </span><span class="m">06</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>call<span class="w"> </span>1d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span>16e8:<span class="w"> </span>b8<span class="w"> </span><span class="m">78</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x78,%eax +<span class="w"> </span>16ed:<span class="w"> </span>e9<span class="w"> </span><span class="m">95</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>jmp<span class="w"> </span><span class="m">1787</span><span class="w"> </span><phase_3+0x14f> +<span class="w"> </span>16f2:<span class="w"> </span>b8<span class="w"> </span><span class="m">64</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x64,%eax +<span class="w"> </span>16f7:<span class="w"> </span><span class="m">81</span><span class="w"> </span>7c<span class="w"> </span><span class="m">24</span><span class="w"> </span><span class="m">08</span><span class="w"> </span><span class="m">80</span><span class="w"> </span><span class="m">02</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>cmpl<span class="w"> </span><span class="nv">$0</span>x280,0x8<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>16fe:<span class="w"> </span><span class="m">00</span><span class="w"> </span> +<span class="w"> </span>16ff:<span class="w"> </span>0f<span class="w"> </span><span class="m">84</span><span class="w"> </span><span class="m">82</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>je<span class="w"> </span><span class="m">1787</span><span class="w"> </span><phase_3+0x14f> +<span class="w"> </span><span class="m">1705</span>:<span class="w"> </span>e8<span class="w"> </span><span class="m">40</span><span class="w"> </span><span class="m">06</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>call<span class="w"> </span>1d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span>170a:<span class="w"> </span>b8<span class="w"> </span><span class="m">64</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x64,%eax +<span class="w"> </span>170f:<span class="w"> </span>eb<span class="w"> </span><span class="m">76</span><span class="w"> </span>jmp<span class="w"> </span><span class="m">1787</span><span class="w"> </span><phase_3+0x14f> +<span class="w"> </span><span class="m">1711</span>:<span class="w"> </span>b8<span class="w"> </span>6d<span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x6d,%eax +<span class="w"> </span><span class="m">1716</span>:<span class="w"> </span><span class="m">81</span><span class="w"> </span>7c<span class="w"> </span><span class="m">24</span><span class="w"> </span><span class="m">08</span><span class="w"> </span>ff<span class="w"> </span><span class="m">02</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>cmpl<span class="w"> </span><span class="nv">$0</span>x2ff,0x8<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>171d:<span class="w"> </span><span class="m">00</span><span class="w"> </span> +<span class="w"> </span>171e:<span class="w"> </span><span class="m">74</span><span class="w"> </span><span class="m">67</span><span class="w"> </span>je<span class="w"> </span><span class="m">1787</span><span class="w"> </span><phase_3+0x14f> +<span class="w"> </span><span class="m">1720</span>:<span class="w"> </span>e8<span class="w"> </span><span class="m">25</span><span class="w"> </span><span class="m">06</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>call<span class="w"> </span>1d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span><span class="m">1725</span>:<span class="w"> </span>b8<span class="w"> </span>6d<span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x6d,%eax +<span class="w"> </span>172a:<span class="w"> </span>eb<span class="w"> </span>5b<span class="w"> </span>jmp<span class="w"> </span><span class="m">1787</span><span class="w"> </span><phase_3+0x14f> +<span class="w"> </span>172c:<span class="w"> </span>b8<span class="w"> </span><span class="m">71</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x71,%eax +<span class="w"> </span><span class="m">1731</span>:<span class="w"> </span><span class="m">81</span><span class="w"> </span>7c<span class="w"> </span><span class="m">24</span><span class="w"> </span><span class="m">08</span><span class="w"> </span><span class="m">75</span><span class="w"> </span><span class="m">03</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>cmpl<span class="w"> </span><span class="nv">$0</span>x375,0x8<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span><span class="m">1738</span>:<span class="w"> </span><span class="m">00</span><span class="w"> </span> +<span class="w"> </span><span class="m">1739</span>:<span class="w"> </span><span class="m">74</span><span class="w"> </span>4c<span class="w"> </span>je<span class="w"> </span><span class="m">1787</span><span class="w"> </span><phase_3+0x14f> +<span class="w"> </span>173b:<span class="w"> </span>e8<span class="w"> </span>0a<span class="w"> </span><span class="m">06</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>call<span class="w"> </span>1d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span><span class="m">1740</span>:<span class="w"> </span>b8<span class="w"> </span><span class="m">71</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x71,%eax +<span class="w"> </span><span class="m">1745</span>:<span class="w"> </span>eb<span class="w"> </span><span class="m">40</span><span class="w"> </span>jmp<span class="w"> </span><span class="m">1787</span><span class="w"> </span><phase_3+0x14f> +<span class="w"> </span><span class="m">1747</span>:<span class="w"> </span>b8<span class="w"> </span><span class="m">79</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x79,%eax +<span class="w"> </span>174c:<span class="w"> </span><span class="m">81</span><span class="w"> </span>7c<span class="w"> </span><span class="m">24</span><span class="w"> </span><span class="m">08</span><span class="w"> </span><span class="m">94</span><span class="w"> </span><span class="m">02</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>cmpl<span class="w"> </span><span class="nv">$0</span>x294,0x8<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span><span class="m">1753</span>:<span class="w"> </span><span class="m">00</span><span class="w"> </span> +<span class="w"> </span><span class="m">1754</span>:<span class="w"> </span><span class="m">74</span><span class="w"> </span><span class="m">31</span><span class="w"> </span>je<span class="w"> </span><span class="m">1787</span><span class="w"> </span><phase_3+0x14f> +<span class="w"> </span><span class="m">1756</span>:<span class="w"> </span>e8<span class="w"> </span>ef<span class="w"> </span><span class="m">05</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>call<span class="w"> </span>1d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span>175b:<span class="w"> </span>b8<span class="w"> </span><span class="m">79</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x79,%eax +<span class="w"> </span><span class="m">1760</span>:<span class="w"> </span>eb<span class="w"> </span><span class="m">25</span><span class="w"> </span>jmp<span class="w"> </span><span class="m">1787</span><span class="w"> </span><phase_3+0x14f> +<span class="w"> </span><span class="m">1762</span>:<span class="w"> </span>b8<span class="w"> </span><span class="m">79</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x79,%eax +<span class="w"> </span><span class="m">1767</span>:<span class="w"> </span><span class="m">81</span><span class="w"> </span>7c<span class="w"> </span><span class="m">24</span><span class="w"> </span><span class="m">08</span><span class="w"> </span><span class="m">88</span><span class="w"> </span><span class="m">02</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>cmpl<span class="w"> </span><span class="nv">$0</span>x288,0x8<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>176e:<span class="w"> </span><span class="m">00</span><span class="w"> </span> +<span class="w"> </span>176f:<span class="w"> </span><span class="m">74</span><span class="w"> </span><span class="m">16</span><span class="w"> </span>je<span class="w"> </span><span class="m">1787</span><span class="w"> </span><phase_3+0x14f> +<span class="w"> </span><span class="m">1771</span>:<span class="w"> </span>e8<span class="w"> </span>d4<span class="w"> </span><span class="m">05</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>call<span class="w"> </span>1d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span><span class="m">1776</span>:<span class="w"> </span>b8<span class="w"> </span><span class="m">79</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x79,%eax +<span class="w"> </span>177b:<span class="w"> </span>eb<span class="w"> </span>0a<span class="w"> </span>jmp<span class="w"> </span><span class="m">1787</span><span class="w"> </span><phase_3+0x14f> +<span class="w"> </span>177d:<span class="w"> </span>e8<span class="w"> </span>c8<span class="w"> </span><span class="m">05</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>call<span class="w"> </span>1d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span><span class="m">1782</span>:<span class="w"> </span>b8<span class="w"> </span><span class="m">68</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x68,%eax +<span class="w"> </span><span class="m">1787</span>:<span class="w"> </span><span class="m">38</span><span class="w"> </span><span class="m">44</span><span class="w"> </span><span class="m">24</span><span class="w"> </span><span class="m">07</span><span class="w"> </span>cmp<span class="w"> </span>%al,0x7<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>178b:<span class="w"> </span><span class="m">75</span><span class="w"> </span><span class="m">05</span><span class="w"> </span>jne<span class="w"> </span><span class="m">1792</span><span class="w"> </span><phase_3+0x15a> +<span class="w"> </span>178d:<span class="w"> </span><span class="m">48</span><span class="w"> </span><span class="m">83</span><span class="w"> </span>c4<span class="w"> </span><span class="m">18</span><span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x18,%rsp +<span class="w"> </span><span class="m">1791</span>:<span class="w"> </span>c3<span class="w"> </span>ret<span class="w"> </span> +<span class="w"> </span><span class="m">1792</span>:<span class="w"> </span>e8<span class="w"> </span>b3<span class="w"> </span><span class="m">05</span><span class="w"> </span><span class="m">00</span><span class="w"> </span><span class="m">00</span><span class="w"> </span>call<span class="w"> </span>1d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span><span class="m">1797</span>:<span class="w"> </span>eb<span class="w"> </span>f4<span class="w"> </span>jmp<span class="w"> </span>178d<span class="w"> </span><phase_3+0x155> </code></pre> </div> <div class="codehilite"> <pre><span></span><code>... - 165b: e8 <span class="m">80</span> <span class="nb">fc</span> ff ff call 12e0 <__isoc99_sscanf@plt> +<span class="w"> </span>165b:<span class="w"> </span>e8<span class="w"> </span><span class="m">80</span><span class="w"> </span><span class="nb">fc</span><span class="w"> </span>ff<span class="w"> </span>ff<span class="w"> </span>call<span class="w"> </span>12e0<span class="w"> </span><__isoc99_sscanf@plt> ... </code></pre> </div> @@ -350,82 +354,82 @@ That<span class="err">'</span>s number <span class="m">2</span>. Keep going <p>Because I do not want to enter the solutions to phases 1 and 2 again and again, I am goig to pass a file which has these solutions.</p> <div class="codehilite"> -<pre><span></span><code>joxxxn@jupyter-nxxh6xx8:~/lab2-bomblab-navanchauhan/bombbomb$ gdb -ex <span class="s1">'break phase_3'</span> -ex <span class="s1">'break explode_bomb'</span> -ex <span class="s1">'run'</span> -args ./bomb sol.txt -GNU gdb <span class="o">(</span>Ubuntu <span class="m">12</span>.1-0ubuntu1~22.04<span class="o">)</span> <span class="m">12</span>.1 -Copyright <span class="o">(</span>C<span class="o">)</span> <span class="m">2022</span> Free Software Foundation, Inc. -License GPLv3+: GNU GPL version <span class="m">3</span> or later <http://gnu.org/licenses/gpl.html> -This is free software: you are free to change and redistribute it. -There is NO WARRANTY, to the extent permitted by law. -Type <span class="s2">"show copying"</span> and <span class="s2">"show warranty"</span> <span class="k">for</span> details. -This GDB was configured as <span class="s2">"x86_64-linux-gnu"</span>. -Type <span class="s2">"show configuration"</span> <span class="k">for</span> configuration details. -For bug reporting instructions, please see: +<pre><span></span><code>joxxxn@jupyter-nxxh6xx8:~/lab2-bomblab-navanchauhan/bombbomb$<span class="w"> </span>gdb<span class="w"> </span>-ex<span class="w"> </span><span class="s1">'break phase_3'</span><span class="w"> </span>-ex<span class="w"> </span><span class="s1">'break explode_bomb'</span><span class="w"> </span>-ex<span class="w"> </span><span class="s1">'run'</span><span class="w"> </span>-args<span class="w"> </span>./bomb<span class="w"> </span>sol.txt<span class="w"> </span> +GNU<span class="w"> </span>gdb<span class="w"> </span><span class="o">(</span>Ubuntu<span class="w"> </span><span class="m">12</span>.1-0ubuntu1~22.04<span class="o">)</span><span class="w"> </span><span class="m">12</span>.1 +Copyright<span class="w"> </span><span class="o">(</span>C<span class="o">)</span><span class="w"> </span><span class="m">2022</span><span class="w"> </span>Free<span class="w"> </span>Software<span class="w"> </span>Foundation,<span class="w"> </span>Inc. +License<span class="w"> </span>GPLv3+:<span class="w"> </span>GNU<span class="w"> </span>GPL<span class="w"> </span>version<span class="w"> </span><span class="m">3</span><span class="w"> </span>or<span class="w"> </span>later<span class="w"> </span><http://gnu.org/licenses/gpl.html> +This<span class="w"> </span>is<span class="w"> </span>free<span class="w"> </span>software:<span class="w"> </span>you<span class="w"> </span>are<span class="w"> </span>free<span class="w"> </span>to<span class="w"> </span>change<span class="w"> </span>and<span class="w"> </span>redistribute<span class="w"> </span>it. +There<span class="w"> </span>is<span class="w"> </span>NO<span class="w"> </span>WARRANTY,<span class="w"> </span>to<span class="w"> </span>the<span class="w"> </span>extent<span class="w"> </span>permitted<span class="w"> </span>by<span class="w"> </span>law. +Type<span class="w"> </span><span class="s2">"show copying"</span><span class="w"> </span>and<span class="w"> </span><span class="s2">"show warranty"</span><span class="w"> </span><span class="k">for</span><span class="w"> </span>details. +This<span class="w"> </span>GDB<span class="w"> </span>was<span class="w"> </span>configured<span class="w"> </span>as<span class="w"> </span><span class="s2">"x86_64-linux-gnu"</span>. +Type<span class="w"> </span><span class="s2">"show configuration"</span><span class="w"> </span><span class="k">for</span><span class="w"> </span>configuration<span class="w"> </span>details. +For<span class="w"> </span>bug<span class="w"> </span>reporting<span class="w"> </span>instructions,<span class="w"> </span>please<span class="w"> </span>see: <https://www.gnu.org/software/gdb/bugs/>. -Find the GDB manual and other documentation resources online at: - <http://www.gnu.org/software/gdb/documentation/>. - -For help, <span class="nb">type</span> <span class="s2">"help"</span>. -Type <span class="s2">"apropos word"</span> to search <span class="k">for</span> commands related to <span class="s2">"word"</span>... -Reading symbols from ./bomb... -Breakpoint <span class="m">1</span> at 0x1638 -Breakpoint <span class="m">2</span> at 0x1d4a -Starting program: /home/joxxxn/lab2-bomblab-navanchauhan/bombbomb/bomb sol.txt -<span class="o">[</span>Thread debugging using libthread_db enabled<span class="o">]</span> -Using host libthread_db library <span class="s2">"/lib/x86_64-linux-gnu/libthread_db.so.1"</span>. -Welcome to my fiendish little bomb. You have <span class="m">6</span> phases with -which to blow yourself up. Have a nice day! -Phase <span class="m">1</span> defused. How about the next one? -That<span class="err">'</span>s number <span class="m">2</span>. Keep going! -random string - -Breakpoint <span class="m">1</span>, 0x0000555555555638 <span class="k">in</span> phase_3 <span class="o">()</span> -<span class="o">(</span>gdb<span class="o">)</span> disas -Dump of assembler code <span class="k">for</span> <span class="k">function</span> phase_3: -<span class="o">=</span>> 0x0000555555555638 <+0>: endbr64 - 0x000055555555563c <+4>: sub <span class="nv">$0</span>x18,%rsp - 0x0000555555555640 <+8>: lea 0x7<span class="o">(</span>%rsp<span class="o">)</span>,%rcx - 0x0000555555555645 <+13>: lea 0xc<span class="o">(</span>%rsp<span class="o">)</span>,%rdx - 0x000055555555564a <+18>: lea 0x8<span class="o">(</span>%rsp<span class="o">)</span>,%r8 - 0x000055555555564f <+23>: lea 0x1b60<span class="o">(</span>%rip<span class="o">)</span>,%rsi <span class="c1"># 0x5555555571b6</span> - 0x0000555555555656 <+30>: mov <span class="nv">$0</span>x0,%eax - 0x000055555555565b <+35>: call 0x5555555552e0 <__isoc99_sscanf@plt> - 0x0000555555555660 <+40>: cmp <span class="nv">$0</span>x2,%eax - 0x0000555555555663 <+43>: jle 0x555555555685 <phase_3+77> - 0x0000555555555665 <+45>: cmpl <span class="nv">$0</span>x7,0xc<span class="o">(</span>%rsp<span class="o">)</span> - 0x000055555555566a <+50>: ja 0x55555555577d <phase_3+325> - 0x0000555555555670 <+56>: mov 0xc<span class="o">(</span>%rsp<span class="o">)</span>,%eax - 0x0000555555555674 <+60>: lea 0x1b55<span class="o">(</span>%rip<span class="o">)</span>,%rdx <span class="c1"># 0x5555555571d0</span> - 0x000055555555567b <+67>: movslq <span class="o">(</span>%rdx,%rax,4<span class="o">)</span>,%rax - 0x000055555555567f <+71>: add %rdx,%rax - 0x0000555555555682 <+74>: notrack jmp *%rax - 0x0000555555555685 <+77>: call 0x555555555d4a <explode_bomb> - 0x000055555555568a <+82>: jmp 0x555555555665 <phase_3+45> - 0x000055555555568c <+84>: mov <span class="nv">$0</span>x63,%eax - 0x0000555555555691 <+89>: cmpl <span class="nv">$0</span>x23d,0x8<span class="o">(</span>%rsp<span class="o">)</span> - 0x0000555555555699 <+97>: je 0x555555555787 <phase_3+335> - 0x000055555555569f <+103>: call 0x555555555d4a <explode_bomb> - 0x00005555555556a4 <+108>: mov <span class="nv">$0</span>x63,%eax - 0x00005555555556a9 <+113>: jmp 0x555555555787 <phase_3+335> ---Type <RET> <span class="k">for</span> more, q to quit, c to <span class="k">continue</span> without paging-- +Find<span class="w"> </span>the<span class="w"> </span>GDB<span class="w"> </span>manual<span class="w"> </span>and<span class="w"> </span>other<span class="w"> </span>documentation<span class="w"> </span>resources<span class="w"> </span>online<span class="w"> </span>at: +<span class="w"> </span><http://www.gnu.org/software/gdb/documentation/>. + +For<span class="w"> </span>help,<span class="w"> </span><span class="nb">type</span><span class="w"> </span><span class="s2">"help"</span>. +Type<span class="w"> </span><span class="s2">"apropos word"</span><span class="w"> </span>to<span class="w"> </span>search<span class="w"> </span><span class="k">for</span><span class="w"> </span>commands<span class="w"> </span>related<span class="w"> </span>to<span class="w"> </span><span class="s2">"word"</span>... +Reading<span class="w"> </span>symbols<span class="w"> </span>from<span class="w"> </span>./bomb... +Breakpoint<span class="w"> </span><span class="m">1</span><span class="w"> </span>at<span class="w"> </span>0x1638 +Breakpoint<span class="w"> </span><span class="m">2</span><span class="w"> </span>at<span class="w"> </span>0x1d4a +Starting<span class="w"> </span>program:<span class="w"> </span>/home/joxxxn/lab2-bomblab-navanchauhan/bombbomb/bomb<span class="w"> </span>sol.txt +<span class="o">[</span>Thread<span class="w"> </span>debugging<span class="w"> </span>using<span class="w"> </span>libthread_db<span class="w"> </span>enabled<span class="o">]</span> +Using<span class="w"> </span>host<span class="w"> </span>libthread_db<span class="w"> </span>library<span class="w"> </span><span class="s2">"/lib/x86_64-linux-gnu/libthread_db.so.1"</span>. +Welcome<span class="w"> </span>to<span class="w"> </span>my<span class="w"> </span>fiendish<span class="w"> </span>little<span class="w"> </span>bomb.<span class="w"> </span>You<span class="w"> </span>have<span class="w"> </span><span class="m">6</span><span class="w"> </span>phases<span class="w"> </span>with +which<span class="w"> </span>to<span class="w"> </span>blow<span class="w"> </span>yourself<span class="w"> </span>up.<span class="w"> </span>Have<span class="w"> </span>a<span class="w"> </span>nice<span class="w"> </span>day! +Phase<span class="w"> </span><span class="m">1</span><span class="w"> </span>defused.<span class="w"> </span>How<span class="w"> </span>about<span class="w"> </span>the<span class="w"> </span>next<span class="w"> </span>one? +That<span class="err">'</span>s<span class="w"> </span>number<span class="w"> </span><span class="m">2</span>.<span class="w"> </span>Keep<span class="w"> </span>going! +random<span class="w"> </span>string + +Breakpoint<span class="w"> </span><span class="m">1</span>,<span class="w"> </span>0x0000555555555638<span class="w"> </span><span class="k">in</span><span class="w"> </span>phase_3<span class="w"> </span><span class="o">()</span> +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span>disas +Dump<span class="w"> </span>of<span class="w"> </span>assembler<span class="w"> </span>code<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="k">function</span><span class="w"> </span>phase_3: +<span class="o">=</span>><span class="w"> </span>0x0000555555555638<span class="w"> </span><+0>:<span class="w"> </span>endbr64<span class="w"> </span> +<span class="w"> </span>0x000055555555563c<span class="w"> </span><+4>:<span class="w"> </span>sub<span class="w"> </span><span class="nv">$0</span>x18,%rsp +<span class="w"> </span>0x0000555555555640<span class="w"> </span><+8>:<span class="w"> </span>lea<span class="w"> </span>0x7<span class="o">(</span>%rsp<span class="o">)</span>,%rcx +<span class="w"> </span>0x0000555555555645<span class="w"> </span><+13>:<span class="w"> </span>lea<span class="w"> </span>0xc<span class="o">(</span>%rsp<span class="o">)</span>,%rdx +<span class="w"> </span>0x000055555555564a<span class="w"> </span><+18>:<span class="w"> </span>lea<span class="w"> </span>0x8<span class="o">(</span>%rsp<span class="o">)</span>,%r8 +<span class="w"> </span>0x000055555555564f<span class="w"> </span><+23>:<span class="w"> </span>lea<span class="w"> </span>0x1b60<span class="o">(</span>%rip<span class="o">)</span>,%rsi<span class="w"> </span><span class="c1"># 0x5555555571b6</span> +<span class="w"> </span>0x0000555555555656<span class="w"> </span><+30>:<span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x0,%eax +<span class="w"> </span>0x000055555555565b<span class="w"> </span><+35>:<span class="w"> </span>call<span class="w"> </span>0x5555555552e0<span class="w"> </span><__isoc99_sscanf@plt> +<span class="w"> </span>0x0000555555555660<span class="w"> </span><+40>:<span class="w"> </span>cmp<span class="w"> </span><span class="nv">$0</span>x2,%eax +<span class="w"> </span>0x0000555555555663<span class="w"> </span><+43>:<span class="w"> </span>jle<span class="w"> </span>0x555555555685<span class="w"> </span><phase_3+77> +<span class="w"> </span>0x0000555555555665<span class="w"> </span><+45>:<span class="w"> </span>cmpl<span class="w"> </span><span class="nv">$0</span>x7,0xc<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>0x000055555555566a<span class="w"> </span><+50>:<span class="w"> </span>ja<span class="w"> </span>0x55555555577d<span class="w"> </span><phase_3+325> +<span class="w"> </span>0x0000555555555670<span class="w"> </span><+56>:<span class="w"> </span>mov<span class="w"> </span>0xc<span class="o">(</span>%rsp<span class="o">)</span>,%eax +<span class="w"> </span>0x0000555555555674<span class="w"> </span><+60>:<span class="w"> </span>lea<span class="w"> </span>0x1b55<span class="o">(</span>%rip<span class="o">)</span>,%rdx<span class="w"> </span><span class="c1"># 0x5555555571d0</span> +<span class="w"> </span>0x000055555555567b<span class="w"> </span><+67>:<span class="w"> </span>movslq<span class="w"> </span><span class="o">(</span>%rdx,%rax,4<span class="o">)</span>,%rax +<span class="w"> </span>0x000055555555567f<span class="w"> </span><+71>:<span class="w"> </span>add<span class="w"> </span>%rdx,%rax +<span class="w"> </span>0x0000555555555682<span class="w"> </span><+74>:<span class="w"> </span>notrack<span class="w"> </span>jmp<span class="w"> </span>*%rax +<span class="w"> </span>0x0000555555555685<span class="w"> </span><+77>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span>0x000055555555568a<span class="w"> </span><+82>:<span class="w"> </span>jmp<span class="w"> </span>0x555555555665<span class="w"> </span><phase_3+45> +<span class="w"> </span>0x000055555555568c<span class="w"> </span><+84>:<span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x63,%eax +<span class="w"> </span>0x0000555555555691<span class="w"> </span><+89>:<span class="w"> </span>cmpl<span class="w"> </span><span class="nv">$0</span>x23d,0x8<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>0x0000555555555699<span class="w"> </span><+97>:<span class="w"> </span>je<span class="w"> </span>0x555555555787<span class="w"> </span><phase_3+335> +<span class="w"> </span>0x000055555555569f<span class="w"> </span><+103>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span>0x00005555555556a4<span class="w"> </span><+108>:<span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x63,%eax +<span class="w"> </span>0x00005555555556a9<span class="w"> </span><+113>:<span class="w"> </span>jmp<span class="w"> </span>0x555555555787<span class="w"> </span><phase_3+335> +--Type<span class="w"> </span><RET><span class="w"> </span><span class="k">for</span><span class="w"> </span>more,<span class="w"> </span>q<span class="w"> </span>to<span class="w"> </span>quit,<span class="w"> </span>c<span class="w"> </span>to<span class="w"> </span><span class="k">continue</span><span class="w"> </span>without<span class="w"> </span>paging-- </code></pre> </div> <p><code>gdb</code> has thankfully marked the address which is being passed to <code>scanf</code>. We can access the value:</p> <div class="codehilite"> -<pre><span></span><code><span class="o">(</span>gdb<span class="o">)</span> x/1s 0x5555555571b6 -0x5555555571b6: <span class="s2">"%d %c %d"</span> -<span class="o">(</span>gdb<span class="o">)</span> +<pre><span></span><code><span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span>x/1s<span class="w"> </span>0x5555555571b6 +0x5555555571b6:<span class="w"> </span><span class="s2">"%d %c %d"</span> +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span> </code></pre> </div> <p>BINGO! The program expects an integer, character, and another integer. Onwards.</p> <div class="codehilite"> -<pre><span></span><code> 0x0000555555555660 <+40>: cmp <span class="nv">$0</span>x2,%eax - 0x0000555555555663 <+43>: jle 0x555555555685 <phase_3+77> +<pre><span></span><code><span class="w"> </span>0x0000555555555660<span class="w"> </span><+40>:<span class="w"> </span>cmp<span class="w"> </span><span class="nv">$0</span>x2,%eax +<span class="w"> </span>0x0000555555555663<span class="w"> </span><+43>:<span class="w"> </span>jle<span class="w"> </span>0x555555555685<span class="w"> </span><phase_3+77> ... - 0x0000555555555685 <+77>: call 0x555555555d4a <explode_bomb> +<span class="w"> </span>0x0000555555555685<span class="w"> </span><+77>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> </code></pre> </div> @@ -434,23 +438,24 @@ Dump of assembler code <span class="k">for</span> <span class="k">function</span <p><em>Note: <code>scanf</code> returns the number of fields that were succesfully converted and assigned</em></p> <div class="codehilite"> -<pre><span></span><code> 0x0000555555555665 <+45>: cmpl <span class="nv">$0</span>x7,0xc<span class="o">(</span>%rsp<span class="o">)</span> - 0x000055555555566a <+50>: ja 0x55555555577d <phase_3+325> +<pre><span></span><code><span class="w"> </span>0x0000555555555665<span class="w"> </span><+45>:<span class="w"> </span>cmpl<span class="w"> </span><span class="nv">$0</span>x7,0xc<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>0x000055555555566a<span class="w"> </span><+50>:<span class="w"> </span>ja<span class="w"> </span>0x55555555577d<span class="w"> </span><phase_3+325> ... - 0x000055555555577d <+325>: call 0x555555555d4a <explode_bomb> +<span class="w"> </span>0x000055555555577d<span class="w"> </span><+325>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> </code></pre> </div> -<p>Similarly, the program checks and ensures the returned value is not > 7. - <div class="codehilite"> - <pre><span></span><code>0x0000555555555670 <+56>: mov 0xc<span class="o">(</span>%rsp<span class="o">)</span>,%eax - 0x0000555555555674 <+60>: lea 0x1b55<span class="o">(</span>%rip<span class="o">)</span>,%rdx <span class="c1"># 0x5555555571d0</span> - 0x000055555555567b <+67>: movslq <span class="o">(</span>%rdx,%rax,4<span class="o">)</span>,%rax - 0x000055555555567f <+71>: add %rdx,%rax - 0x0000555555555682 <+74>: notrack jmp *%rax - 0x0000555555555685 <+77>: call 0x555555555d4a <explode_bomb> - </code></pre> - </div></p> +<p>Similarly, the program checks and ensures the returned value is not > 7. </p> + +<div class="codehilite"> +<pre><span></span><code><span class="w"> </span>0x0000555555555670<span class="w"> </span><+56>:<span class="w"> </span>mov<span class="w"> </span>0xc<span class="o">(</span>%rsp<span class="o">)</span>,%eax +<span class="w"> </span>0x0000555555555674<span class="w"> </span><+60>:<span class="w"> </span>lea<span class="w"> </span>0x1b55<span class="o">(</span>%rip<span class="o">)</span>,%rdx<span class="w"> </span><span class="c1"># 0x5555555571d0</span> +<span class="w"> </span>0x000055555555567b<span class="w"> </span><+67>:<span class="w"> </span>movslq<span class="w"> </span><span class="o">(</span>%rdx,%rax,4<span class="o">)</span>,%rax +<span class="w"> </span>0x000055555555567f<span class="w"> </span><+71>:<span class="w"> </span>add<span class="w"> </span>%rdx,%rax +<span class="w"> </span>0x0000555555555682<span class="w"> </span><+74>:<span class="w"> </span>notrack<span class="w"> </span>jmp<span class="w"> </span>*%rax +<span class="w"> </span>0x0000555555555685<span class="w"> </span><+77>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> +</code></pre> +</div> <ul> <li><code>0x0000555555555670 <+56>: mov 0xc(%rsp),%eax</code> - Moves value located at <code>0xc</code> (12 in Decimal) bytes above the stack pointer to <code>%eax</code> register. </li> @@ -480,34 +485,36 @@ $1 = 3 <p><img src="/assets/bomb-lab/phase-3.png" alt="Screenshot of GDB terminal depicting us checking the value of the instruction to be jumped to" /></p> -<p>We can see that this makes us jump to <code><phase_3+186></code> (Continue to step through the code by using <code>ni</code>) - <div class="codehilite"> - <pre><span></span><code>0x00005555555556f2 <+186>: mov <span class="nv">$0</span>x64,%eax - 0x00005555555556f7 <+191>: cmpl <span class="nv">$0</span>x280,0x8<span class="o">(</span>%rsp<span class="o">)</span> - 0x00005555555556ff <+199>: je 0x555555555787 <phase<em>3+335> - 0x0000555555555705 <+205>: call 0x555555555d4a <explode</em>bomb> - </code></pre> - </div></p> - -<p>We see that <code>0x64</code> (Decimal 100) is being stored in <code>%eax</code>. Then, the program compares <code>0x280</code> (Decimal 640) with memory address <code>0x8</code> bytes above the stack pointer (<code>%rsp</code>). If the values are equal, then it jumps to <code><phase_3+335></code>, otherwise <code>explode_bomb</code> is called. - <div class="codehilite"> - <pre><span></span><code>0x0000555555555787 <+335>: cmp %al,0x7<span class="o">(</span>%rsp<span class="o">)</span> - 0x000055555555578b <+339>: jne 0x555555555792 <phase<em>3+346> - 0x000055555555578d <+341>: add <span class="nv">$0</span>x18,%rsp - 0x0000555555555791 <+345>: ret <br /> - 0x0000555555555792 <+346>: call 0x555555555d4a <explode</em>bomb> - </code></pre> - </div></p> +<p>We can see that this makes us jump to <code><phase_3+186></code> (Continue to step through the code by using <code>ni</code>)</p> + +<div class="codehilite"> +<pre><span></span><code><span class="w"> </span>0x00005555555556f2<span class="w"> </span><+186>:<span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x64,%eax +<span class="w"> </span>0x00005555555556f7<span class="w"> </span><+191>:<span class="w"> </span>cmpl<span class="w"> </span><span class="nv">$0</span>x280,0x8<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>0x00005555555556ff<span class="w"> </span><+199>:<span class="w"> </span>je<span class="w"> </span>0x555555555787<span class="w"> </span><phase_3+335> +<span class="w"> </span>0x0000555555555705<span class="w"> </span><+205>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> +</code></pre> +</div> + +<p>We see that <code>0x64</code> (Decimal 100) is being stored in <code>%eax</code>. Then, the program compares <code>0x280</code> (Decimal 640) with memory address <code>0x8</code> bytes above the stack pointer (<code>%rsp</code>). If the values are equal, then it jumps to <code><phase_3+335></code>, otherwise <code>explode_bomb</code> is called.</p> + +<div class="codehilite"> +<pre><span></span><code><span class="w"> </span>0x0000555555555787<span class="w"> </span><+335>:<span class="w"> </span>cmp<span class="w"> </span>%al,0x7<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>0x000055555555578b<span class="w"> </span><+339>:<span class="w"> </span>jne<span class="w"> </span>0x555555555792<span class="w"> </span><phase_3+346> +<span class="w"> </span>0x000055555555578d<span class="w"> </span><+341>:<span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x18,%rsp +<span class="w"> </span>0x0000555555555791<span class="w"> </span><+345>:<span class="w"> </span>ret<span class="w"> </span> +<span class="w"> </span>0x0000555555555792<span class="w"> </span><+346>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> +</code></pre> +</div> <p>Here, the program is comparing the value of our given character to the value stored in <code>%al</code> (lower 8 bits of <code>EAX</code>), and checks if they are not equal.</p> <p>Knowing that the character is stored at an offset of 7 bytes to <code>%rsp</code>, we can print and check the value by running:</p> <div class="codehilite"> -<pre><span></span><code><span class="o">(</span>gdb<span class="o">)</span> x/1cw <span class="nv">$rsp</span>+7 +<pre><span></span><code><span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span>x/1cw<span class="w"> </span><span class="nv">$rsp</span>+7 c -<span class="o">(</span>gdb<span class="o">)</span> print <span class="nv">$al</span> -<span class="nv">$1</span> <span class="o">=</span> <span class="m">100</span> +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span>print<span class="w"> </span><span class="nv">$al</span> +<span class="nv">$1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="m">100</span> </code></pre> </div> @@ -515,114 +522,116 @@ c <div class="codehilite"> <pre><span></span><code>... -That<span class="err">'</span>s number <span class="m">2</span>. Keep going! -<span class="m">3</span> d <span class="m">640</span> +That<span class="err">'</span>s<span class="w"> </span>number<span class="w"> </span><span class="m">2</span>.<span class="w"> </span>Keep<span class="w"> </span>going! +<span class="m">3</span><span class="w"> </span>d<span class="w"> </span><span class="m">640</span> -Breakpoint <span class="m">1</span>, 0x0000555555555638 <span class="k">in</span> phase_3 <span class="o">()</span> -<span class="o">(</span>gdb<span class="o">)</span> <span class="k">continue</span> +Breakpoint<span class="w"> </span><span class="m">1</span>,<span class="w"> </span>0x0000555555555638<span class="w"> </span><span class="k">in</span><span class="w"> </span>phase_3<span class="w"> </span><span class="o">()</span> +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span><span class="k">continue</span> Continuing. -Halfway there! +Halfway<span class="w"> </span>there! </code></pre> </div> <h2>Phase 4</h2> <div class="codehilite"> -<pre><span></span><code>joxxxn@jupyter-nxxh6xx8:~/lab2-bomblab-navanchauhan/bombbomb$ gdb -ex <span class="s1">'break phase_4'</span> -ex <span class="s1">'break explode_bomb'</span> -ex <span class="s1">'run'</span> -args ./bomb sol.txt -GNU gdb <span class="o">(</span>Ubuntu <span class="m">12</span>.1-0ubuntu1~22.04<span class="o">)</span> <span class="m">12</span>.1 -Copyright <span class="o">(</span>C<span class="o">)</span> <span class="m">2022</span> Free Software Foundation, Inc. -License GPLv3+: GNU GPL version <span class="m">3</span> or later <http://gnu.org/licenses/gpl.html> -This is free software: you are free to change and redistribute it. -There is NO WARRANTY, to the extent permitted by law. -Type <span class="s2">"show copying"</span> and <span class="s2">"show warranty"</span> <span class="k">for</span> details. -This GDB was configured as <span class="s2">"x86_64-linux-gnu"</span>. -Type <span class="s2">"show configuration"</span> <span class="k">for</span> configuration details. -For bug reporting instructions, please see: +<pre><span></span><code>joxxxn@jupyter-nxxh6xx8:~/lab2-bomblab-navanchauhan/bombbomb$<span class="w"> </span>gdb<span class="w"> </span>-ex<span class="w"> </span><span class="s1">'break phase_4'</span><span class="w"> </span>-ex<span class="w"> </span><span class="s1">'break explode_bomb'</span><span class="w"> </span>-ex<span class="w"> </span><span class="s1">'run'</span><span class="w"> </span>-args<span class="w"> </span>./bomb<span class="w"> </span>sol.txt<span class="w"> </span> +GNU<span class="w"> </span>gdb<span class="w"> </span><span class="o">(</span>Ubuntu<span class="w"> </span><span class="m">12</span>.1-0ubuntu1~22.04<span class="o">)</span><span class="w"> </span><span class="m">12</span>.1 +Copyright<span class="w"> </span><span class="o">(</span>C<span class="o">)</span><span class="w"> </span><span class="m">2022</span><span class="w"> </span>Free<span class="w"> </span>Software<span class="w"> </span>Foundation,<span class="w"> </span>Inc. +License<span class="w"> </span>GPLv3+:<span class="w"> </span>GNU<span class="w"> </span>GPL<span class="w"> </span>version<span class="w"> </span><span class="m">3</span><span class="w"> </span>or<span class="w"> </span>later<span class="w"> </span><http://gnu.org/licenses/gpl.html> +This<span class="w"> </span>is<span class="w"> </span>free<span class="w"> </span>software:<span class="w"> </span>you<span class="w"> </span>are<span class="w"> </span>free<span class="w"> </span>to<span class="w"> </span>change<span class="w"> </span>and<span class="w"> </span>redistribute<span class="w"> </span>it. +There<span class="w"> </span>is<span class="w"> </span>NO<span class="w"> </span>WARRANTY,<span class="w"> </span>to<span class="w"> </span>the<span class="w"> </span>extent<span class="w"> </span>permitted<span class="w"> </span>by<span class="w"> </span>law. +Type<span class="w"> </span><span class="s2">"show copying"</span><span class="w"> </span>and<span class="w"> </span><span class="s2">"show warranty"</span><span class="w"> </span><span class="k">for</span><span class="w"> </span>details. +This<span class="w"> </span>GDB<span class="w"> </span>was<span class="w"> </span>configured<span class="w"> </span>as<span class="w"> </span><span class="s2">"x86_64-linux-gnu"</span>. +Type<span class="w"> </span><span class="s2">"show configuration"</span><span class="w"> </span><span class="k">for</span><span class="w"> </span>configuration<span class="w"> </span>details. +For<span class="w"> </span>bug<span class="w"> </span>reporting<span class="w"> </span>instructions,<span class="w"> </span>please<span class="w"> </span>see: <https://www.gnu.org/software/gdb/bugs/>. -Find the GDB manual and other documentation resources online at: - <http://www.gnu.org/software/gdb/documentation/>. - -For help, <span class="nb">type</span> <span class="s2">"help"</span>. -Type <span class="s2">"apropos word"</span> to search <span class="k">for</span> commands related to <span class="s2">"word"</span>... -Reading symbols from ./bomb... -Breakpoint <span class="m">1</span> at 0x17d3 -Breakpoint <span class="m">2</span> at 0x1d4a -Starting program: /home/joxxxn/lab2-bomblab-navanchauhan/bombbomb/bomb sol.txt -<span class="o">[</span>Thread debugging using libthread_db enabled<span class="o">]</span> -Using host libthread_db library <span class="s2">"/lib/x86_64-linux-gnu/libthread_db.so.1"</span>. -Welcome to my fiendish little bomb. You have <span class="m">6</span> phases with -which to blow yourself up. Have a nice day! -Phase <span class="m">1</span> defused. How about the next one? -That<span class="err">'</span>s number <span class="m">2</span>. Keep going! -Halfway there! -<span class="nb">test</span> string - -Breakpoint <span class="m">1</span>, 0x00005555555557d3 <span class="k">in</span> phase_4 <span class="o">()</span> -<span class="o">(</span>gdb<span class="o">)</span> disas phase_4 -Dump of assembler code <span class="k">for</span> <span class="k">function</span> phase_4: -<span class="o">=</span>> 0x00005555555557d3 <+0>: endbr64 - 0x00005555555557d7 <+4>: sub <span class="nv">$0</span>x18,%rsp - 0x00005555555557db <+8>: lea 0x8<span class="o">(</span>%rsp<span class="o">)</span>,%rcx - 0x00005555555557e0 <+13>: lea 0xc<span class="o">(</span>%rsp<span class="o">)</span>,%rdx - 0x00005555555557e5 <+18>: lea 0x1bba<span class="o">(</span>%rip<span class="o">)</span>,%rsi <span class="c1"># 0x5555555573a6</span> - 0x00005555555557ec <+25>: mov <span class="nv">$0</span>x0,%eax - 0x00005555555557f1 <+30>: call 0x5555555552e0 <__isoc99_sscanf@plt> - 0x00005555555557f6 <+35>: cmp <span class="nv">$0</span>x2,%eax - 0x00005555555557f9 <+38>: jne 0x555555555802 <phase_4+47> - 0x00005555555557fb <+40>: cmpl <span class="nv">$0</span>xe,0xc<span class="o">(</span>%rsp<span class="o">)</span> - 0x0000555555555800 <+45>: jbe 0x555555555807 <phase_4+52> - 0x0000555555555802 <+47>: call 0x555555555d4a <explode_bomb> - 0x0000555555555807 <+52>: mov <span class="nv">$0</span>xe,%edx - 0x000055555555580c <+57>: mov <span class="nv">$0</span>x0,%esi - 0x0000555555555811 <+62>: mov 0xc<span class="o">(</span>%rsp<span class="o">)</span>,%edi - 0x0000555555555815 <+66>: call 0x555555555799 <func4> - 0x000055555555581a <+71>: cmp <span class="nv">$0</span>x2,%eax - 0x000055555555581d <+74>: jne 0x555555555826 <phase_4+83> - 0x000055555555581f <+76>: cmpl <span class="nv">$0</span>x2,0x8<span class="o">(</span>%rsp<span class="o">)</span> - 0x0000555555555824 <+81>: je 0x55555555582b <phase_4+88> - 0x0000555555555826 <+83>: call 0x555555555d4a <explode_bomb> - 0x000055555555582b <+88>: add <span class="nv">$0</span>x18,%rsp - 0x000055555555582f <+92>: ret -End of assembler dump. -<span class="o">(</span>gdb<span class="o">)</span> +Find<span class="w"> </span>the<span class="w"> </span>GDB<span class="w"> </span>manual<span class="w"> </span>and<span class="w"> </span>other<span class="w"> </span>documentation<span class="w"> </span>resources<span class="w"> </span>online<span class="w"> </span>at: +<span class="w"> </span><http://www.gnu.org/software/gdb/documentation/>. + +For<span class="w"> </span>help,<span class="w"> </span><span class="nb">type</span><span class="w"> </span><span class="s2">"help"</span>. +Type<span class="w"> </span><span class="s2">"apropos word"</span><span class="w"> </span>to<span class="w"> </span>search<span class="w"> </span><span class="k">for</span><span class="w"> </span>commands<span class="w"> </span>related<span class="w"> </span>to<span class="w"> </span><span class="s2">"word"</span>... +Reading<span class="w"> </span>symbols<span class="w"> </span>from<span class="w"> </span>./bomb... +Breakpoint<span class="w"> </span><span class="m">1</span><span class="w"> </span>at<span class="w"> </span>0x17d3 +Breakpoint<span class="w"> </span><span class="m">2</span><span class="w"> </span>at<span class="w"> </span>0x1d4a +Starting<span class="w"> </span>program:<span class="w"> </span>/home/joxxxn/lab2-bomblab-navanchauhan/bombbomb/bomb<span class="w"> </span>sol.txt +<span class="o">[</span>Thread<span class="w"> </span>debugging<span class="w"> </span>using<span class="w"> </span>libthread_db<span class="w"> </span>enabled<span class="o">]</span> +Using<span class="w"> </span>host<span class="w"> </span>libthread_db<span class="w"> </span>library<span class="w"> </span><span class="s2">"/lib/x86_64-linux-gnu/libthread_db.so.1"</span>. +Welcome<span class="w"> </span>to<span class="w"> </span>my<span class="w"> </span>fiendish<span class="w"> </span>little<span class="w"> </span>bomb.<span class="w"> </span>You<span class="w"> </span>have<span class="w"> </span><span class="m">6</span><span class="w"> </span>phases<span class="w"> </span>with +which<span class="w"> </span>to<span class="w"> </span>blow<span class="w"> </span>yourself<span class="w"> </span>up.<span class="w"> </span>Have<span class="w"> </span>a<span class="w"> </span>nice<span class="w"> </span>day! +Phase<span class="w"> </span><span class="m">1</span><span class="w"> </span>defused.<span class="w"> </span>How<span class="w"> </span>about<span class="w"> </span>the<span class="w"> </span>next<span class="w"> </span>one? +That<span class="err">'</span>s<span class="w"> </span>number<span class="w"> </span><span class="m">2</span>.<span class="w"> </span>Keep<span class="w"> </span>going! +Halfway<span class="w"> </span>there! +<span class="nb">test</span><span class="w"> </span>string + +Breakpoint<span class="w"> </span><span class="m">1</span>,<span class="w"> </span>0x00005555555557d3<span class="w"> </span><span class="k">in</span><span class="w"> </span>phase_4<span class="w"> </span><span class="o">()</span> +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span>disas<span class="w"> </span>phase_4 +Dump<span class="w"> </span>of<span class="w"> </span>assembler<span class="w"> </span>code<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="k">function</span><span class="w"> </span>phase_4: +<span class="o">=</span>><span class="w"> </span>0x00005555555557d3<span class="w"> </span><+0>:<span class="w"> </span>endbr64<span class="w"> </span> +<span class="w"> </span>0x00005555555557d7<span class="w"> </span><+4>:<span class="w"> </span>sub<span class="w"> </span><span class="nv">$0</span>x18,%rsp +<span class="w"> </span>0x00005555555557db<span class="w"> </span><+8>:<span class="w"> </span>lea<span class="w"> </span>0x8<span class="o">(</span>%rsp<span class="o">)</span>,%rcx +<span class="w"> </span>0x00005555555557e0<span class="w"> </span><+13>:<span class="w"> </span>lea<span class="w"> </span>0xc<span class="o">(</span>%rsp<span class="o">)</span>,%rdx +<span class="w"> </span>0x00005555555557e5<span class="w"> </span><+18>:<span class="w"> </span>lea<span class="w"> </span>0x1bba<span class="o">(</span>%rip<span class="o">)</span>,%rsi<span class="w"> </span><span class="c1"># 0x5555555573a6</span> +<span class="w"> </span>0x00005555555557ec<span class="w"> </span><+25>:<span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x0,%eax +<span class="w"> </span>0x00005555555557f1<span class="w"> </span><+30>:<span class="w"> </span>call<span class="w"> </span>0x5555555552e0<span class="w"> </span><__isoc99_sscanf@plt> +<span class="w"> </span>0x00005555555557f6<span class="w"> </span><+35>:<span class="w"> </span>cmp<span class="w"> </span><span class="nv">$0</span>x2,%eax +<span class="w"> </span>0x00005555555557f9<span class="w"> </span><+38>:<span class="w"> </span>jne<span class="w"> </span>0x555555555802<span class="w"> </span><phase_4+47> +<span class="w"> </span>0x00005555555557fb<span class="w"> </span><+40>:<span class="w"> </span>cmpl<span class="w"> </span><span class="nv">$0</span>xe,0xc<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>0x0000555555555800<span class="w"> </span><+45>:<span class="w"> </span>jbe<span class="w"> </span>0x555555555807<span class="w"> </span><phase_4+52> +<span class="w"> </span>0x0000555555555802<span class="w"> </span><+47>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span>0x0000555555555807<span class="w"> </span><+52>:<span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>xe,%edx +<span class="w"> </span>0x000055555555580c<span class="w"> </span><+57>:<span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x0,%esi +<span class="w"> </span>0x0000555555555811<span class="w"> </span><+62>:<span class="w"> </span>mov<span class="w"> </span>0xc<span class="o">(</span>%rsp<span class="o">)</span>,%edi +<span class="w"> </span>0x0000555555555815<span class="w"> </span><+66>:<span class="w"> </span>call<span class="w"> </span>0x555555555799<span class="w"> </span><func4> +<span class="w"> </span>0x000055555555581a<span class="w"> </span><+71>:<span class="w"> </span>cmp<span class="w"> </span><span class="nv">$0</span>x2,%eax +<span class="w"> </span>0x000055555555581d<span class="w"> </span><+74>:<span class="w"> </span>jne<span class="w"> </span>0x555555555826<span class="w"> </span><phase_4+83> +<span class="w"> </span>0x000055555555581f<span class="w"> </span><+76>:<span class="w"> </span>cmpl<span class="w"> </span><span class="nv">$0</span>x2,0x8<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>0x0000555555555824<span class="w"> </span><+81>:<span class="w"> </span>je<span class="w"> </span>0x55555555582b<span class="w"> </span><phase_4+88> +<span class="w"> </span>0x0000555555555826<span class="w"> </span><+83>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span>0x000055555555582b<span class="w"> </span><+88>:<span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x18,%rsp +<span class="w"> </span>0x000055555555582f<span class="w"> </span><+92>:<span class="w"> </span>ret<span class="w"> </span> +End<span class="w"> </span>of<span class="w"> </span>assembler<span class="w"> </span>dump. +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span> </code></pre> </div> <p>Again, <code>gdb</code> has marked the string being passed to <code>scanf</code></p> <div class="codehilite"> -<pre><span></span><code><span class="o">(</span>gdb<span class="o">)</span> x/1s 0x5555555573a6 -0x5555555573a6: <span class="s2">"%d %d"</span> +<pre><span></span><code><span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span>x/1s<span class="w"> </span>0x5555555573a6 +0x5555555573a6:<span class="w"> </span><span class="s2">"%d %d"</span> </code></pre> </div> -<p>Okay, so this time we are supposed to enter 2 numbers. - <div class="codehilite"> - <pre><span></span><code>0x00005555555557f6 <+35>: cmp <span class="nv">$0</span>x2,%eax - 0x00005555555557f9 <+38>: jne 0x555555555802 <phase_4+47> - </code></pre> - </div></p> +<p>Okay, so this time we are supposed to enter 2 numbers.</p> -<p>Checks if there were 2 values read from calling <code>scanf</code>, if not -> jump to <code><phase_4+47></code> which calls <code><explode_bomb></code>. - <div class="codehilite"> - <pre><span></span><code>0x00005555555557fb <+40>: cmpl <span class="nv">$0</span>xe,0xc<span class="o">(</span>%rsp<span class="o">)</span> - 0x0000555555555800 <+45>: jbe 0x555555555807 <phase_4+52> - </code></pre> - </div></p> +<div class="codehilite"> +<pre><span></span><code><span class="w"> </span>0x00005555555557f6<span class="w"> </span><+35>:<span class="w"> </span>cmp<span class="w"> </span><span class="nv">$0</span>x2,%eax +<span class="w"> </span>0x00005555555557f9<span class="w"> </span><+38>:<span class="w"> </span>jne<span class="w"> </span>0x555555555802<span class="w"> </span><phase_4+47> +</code></pre> +</div> + +<p>Checks if there were 2 values read from calling <code>scanf</code>, if not -> jump to <code><phase_4+47></code> which calls <code><explode_bomb></code>.</p> + +<div class="codehilite"> +<pre><span></span><code><span class="w"> </span>0x00005555555557fb<span class="w"> </span><+40>:<span class="w"> </span>cmpl<span class="w"> </span><span class="nv">$0</span>xe,0xc<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>0x0000555555555800<span class="w"> </span><+45>:<span class="w"> </span>jbe<span class="w"> </span>0x555555555807<span class="w"> </span><phase_4+52> +</code></pre> +</div> <p>Compare <code>0xe</code> (14 in Decimal) and value stored at <code>$rsp</code> + <code>0xc</code> bytes (Decimal 12). If this condition is met (<= 14), jump to <code><phase_4+52></code>. If not, then explode bomb.</p> <div class="codehilite"> <pre><span></span><code>... - 0x0000555555555807 <+52>: mov <span class="nv">$0</span>xe,%edx - 0x000055555555580c <+57>: mov <span class="nv">$0</span>x0,%esi - 0x0000555555555811 <+62>: mov 0xc<span class="o">(</span>%rsp<span class="o">)</span>,%edi - 0x0000555555555815 <+66>: call 0x555555555799 <func4> - 0x000055555555581a <+71>: cmp <span class="nv">$0</span>x2,%eax - 0x000055555555581d <+74>: jne 0x555555555826 <phase_4+83> - 0x000055555555581f <+76>: cmpl <span class="nv">$0</span>x2,0x8<span class="o">(</span>%rsp<span class="o">)</span> - 0x0000555555555824 <+81>: je 0x55555555582b <phase_4+88> - 0x0000555555555826 <+83>: call 0x555555555d4a <explode_bomb> +<span class="w"> </span>0x0000555555555807<span class="w"> </span><+52>:<span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>xe,%edx +<span class="w"> </span>0x000055555555580c<span class="w"> </span><+57>:<span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x0,%esi +<span class="w"> </span>0x0000555555555811<span class="w"> </span><+62>:<span class="w"> </span>mov<span class="w"> </span>0xc<span class="o">(</span>%rsp<span class="o">)</span>,%edi +<span class="w"> </span>0x0000555555555815<span class="w"> </span><+66>:<span class="w"> </span>call<span class="w"> </span>0x555555555799<span class="w"> </span><func4> +<span class="w"> </span>0x000055555555581a<span class="w"> </span><+71>:<span class="w"> </span>cmp<span class="w"> </span><span class="nv">$0</span>x2,%eax +<span class="w"> </span>0x000055555555581d<span class="w"> </span><+74>:<span class="w"> </span>jne<span class="w"> </span>0x555555555826<span class="w"> </span><phase_4+83> +<span class="w"> </span>0x000055555555581f<span class="w"> </span><+76>:<span class="w"> </span>cmpl<span class="w"> </span><span class="nv">$0</span>x2,0x8<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>0x0000555555555824<span class="w"> </span><+81>:<span class="w"> </span>je<span class="w"> </span>0x55555555582b<span class="w"> </span><phase_4+88> +<span class="w"> </span>0x0000555555555826<span class="w"> </span><+83>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> </code></pre> </div> @@ -634,28 +643,28 @@ End of assembler dump. <p>Let us look into <code>func4</code></p> <div class="codehilite"> -<pre><span></span><code><span class="o">(</span>gdb<span class="o">)</span> disas func4 -Dump of assembler code <span class="k">for</span> <span class="k">function</span> func4: - 0x0000555555555799 <+0>: endbr64 - 0x000055555555579d <+4>: sub <span class="nv">$0</span>x8,%rsp - 0x00005555555557a1 <+8>: mov %edx,%ecx - 0x00005555555557a3 <+10>: sub %esi,%ecx - 0x00005555555557a5 <+12>: shr %ecx - 0x00005555555557a7 <+14>: add %esi,%ecx - 0x00005555555557a9 <+16>: cmp %edi,%ecx - 0x00005555555557ab <+18>: ja 0x5555555557b9 <func4+32> - 0x00005555555557ad <+20>: mov <span class="nv">$0</span>x0,%eax - 0x00005555555557b2 <+25>: jb 0x5555555557c5 <func4+44> - 0x00005555555557b4 <+27>: add <span class="nv">$0</span>x8,%rsp - 0x00005555555557b8 <+31>: ret - 0x00005555555557b9 <+32>: lea -0x1<span class="o">(</span>%rcx<span class="o">)</span>,%edx - 0x00005555555557bc <+35>: call 0x555555555799 <func4> - 0x00005555555557c1 <+40>: add %eax,%eax - 0x00005555555557c3 <+42>: jmp 0x5555555557b4 <func4+27> - 0x00005555555557c5 <+44>: lea 0x1<span class="o">(</span>%rcx<span class="o">)</span>,%esi - 0x00005555555557c8 <+47>: call 0x555555555799 <func4> - 0x00005555555557cd <+52>: lea 0x1<span class="o">(</span>%rax,%rax,1<span class="o">)</span>,%eax - 0x00005555555557d1 <+56>: jmp 0x5555555557b4 <func4+27> +<pre><span></span><code><span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span>disas<span class="w"> </span>func4 +Dump<span class="w"> </span>of<span class="w"> </span>assembler<span class="w"> </span>code<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="k">function</span><span class="w"> </span>func4: +<span class="w"> </span>0x0000555555555799<span class="w"> </span><+0>:<span class="w"> </span>endbr64<span class="w"> </span> +<span class="w"> </span>0x000055555555579d<span class="w"> </span><+4>:<span class="w"> </span>sub<span class="w"> </span><span class="nv">$0</span>x8,%rsp +<span class="w"> </span>0x00005555555557a1<span class="w"> </span><+8>:<span class="w"> </span>mov<span class="w"> </span>%edx,%ecx +<span class="w"> </span>0x00005555555557a3<span class="w"> </span><+10>:<span class="w"> </span>sub<span class="w"> </span>%esi,%ecx +<span class="w"> </span>0x00005555555557a5<span class="w"> </span><+12>:<span class="w"> </span>shr<span class="w"> </span>%ecx +<span class="w"> </span>0x00005555555557a7<span class="w"> </span><+14>:<span class="w"> </span>add<span class="w"> </span>%esi,%ecx +<span class="w"> </span>0x00005555555557a9<span class="w"> </span><+16>:<span class="w"> </span>cmp<span class="w"> </span>%edi,%ecx +<span class="w"> </span>0x00005555555557ab<span class="w"> </span><+18>:<span class="w"> </span>ja<span class="w"> </span>0x5555555557b9<span class="w"> </span><func4+32> +<span class="w"> </span>0x00005555555557ad<span class="w"> </span><+20>:<span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x0,%eax +<span class="w"> </span>0x00005555555557b2<span class="w"> </span><+25>:<span class="w"> </span>jb<span class="w"> </span>0x5555555557c5<span class="w"> </span><func4+44> +<span class="w"> </span>0x00005555555557b4<span class="w"> </span><+27>:<span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x8,%rsp +<span class="w"> </span>0x00005555555557b8<span class="w"> </span><+31>:<span class="w"> </span>ret<span class="w"> </span> +<span class="w"> </span>0x00005555555557b9<span class="w"> </span><+32>:<span class="w"> </span>lea<span class="w"> </span>-0x1<span class="o">(</span>%rcx<span class="o">)</span>,%edx +<span class="w"> </span>0x00005555555557bc<span class="w"> </span><+35>:<span class="w"> </span>call<span class="w"> </span>0x555555555799<span class="w"> </span><func4> +<span class="w"> </span>0x00005555555557c1<span class="w"> </span><+40>:<span class="w"> </span>add<span class="w"> </span>%eax,%eax +<span class="w"> </span>0x00005555555557c3<span class="w"> </span><+42>:<span class="w"> </span>jmp<span class="w"> </span>0x5555555557b4<span class="w"> </span><func4+27> +<span class="w"> </span>0x00005555555557c5<span class="w"> </span><+44>:<span class="w"> </span>lea<span class="w"> </span>0x1<span class="o">(</span>%rcx<span class="o">)</span>,%esi +<span class="w"> </span>0x00005555555557c8<span class="w"> </span><+47>:<span class="w"> </span>call<span class="w"> </span>0x555555555799<span class="w"> </span><func4> +<span class="w"> </span>0x00005555555557cd<span class="w"> </span><+52>:<span class="w"> </span>lea<span class="w"> </span>0x1<span class="o">(</span>%rax,%rax,1<span class="o">)</span>,%eax +<span class="w"> </span>0x00005555555557d1<span class="w"> </span><+56>:<span class="w"> </span>jmp<span class="w"> </span>0x5555555557b4<span class="w"> </span><func4+27> </code></pre> </div> @@ -665,25 +674,25 @@ Dump of assembler code <span class="k">for</span> <span class="k">function</span <div class="codehilite"> <pre><span></span><code>endbr64 -sub <span class="nv">$0</span>x8,%rsp // subtract <span class="m">8</span> bytes from the stack pointer -mov %edx,%ecx // Move the value <span class="k">in</span> register %edx to %ecx -sub %esi,%ecx // Subtract the value <span class="k">in</span> %esi from %ecx -shr %ecx // Right <span class="nb">shift</span> the value <span class="k">in</span> %ecx by one bit <span class="o">(</span>dividing the value by <span class="m">2</span><span class="o">)</span> -add %esi,%ecx // Add the value <span class="k">in</span> %esi to %ecx -cmp %edi,%ecx // Compare -ja 0x5555555557b9 <func4+32> // If %ecx > %edi -> jump to instruction at offset +32 -mov <span class="nv">$0</span>x0,%eax // Move <span class="m">0</span> to %eax -jb 0x5555555557c5 <func4+44> // If %ecx < %edi -> jump to instruction at offset +44. -add <span class="nv">$0</span>x8,%rsp // add <span class="m">8</span> bytes to the stack pointer -ret // <span class="k">return</span> -lea -0x1<span class="o">(</span>%rcx<span class="o">)</span>,%edx // LEA of <span class="nv">$rxc</span> - <span class="m">1</span> into <span class="nv">$edx</span> -call 0x555555555799 <func4> // Call itself -add %eax,%eax // Double the value <span class="k">in</span> %eax -jmp 0x5555555557b4 <func4+27> // jump to the instruction at offset +27 -lea 0x1<span class="o">(</span>%rcx<span class="o">)</span>,%esi -call 0x555555555799 <func4> -lea 0x1<span class="o">(</span>%rax,%rax,1<span class="o">)</span>,%eax // LEA of %rax * <span class="m">2</span> + <span class="m">1</span> into <span class="nv">$eax</span> -jmp 0x5555555557b4 <func4+27> +sub<span class="w"> </span><span class="nv">$0</span>x8,%rsp<span class="w"> </span>//<span class="w"> </span>subtract<span class="w"> </span><span class="m">8</span><span class="w"> </span>bytes<span class="w"> </span>from<span class="w"> </span>the<span class="w"> </span>stack<span class="w"> </span>pointer +mov<span class="w"> </span>%edx,%ecx<span class="w"> </span>//<span class="w"> </span>Move<span class="w"> </span>the<span class="w"> </span>value<span class="w"> </span><span class="k">in</span><span class="w"> </span>register<span class="w"> </span>%edx<span class="w"> </span>to<span class="w"> </span>%ecx +sub<span class="w"> </span>%esi,%ecx<span class="w"> </span>//<span class="w"> </span>Subtract<span class="w"> </span>the<span class="w"> </span>value<span class="w"> </span><span class="k">in</span><span class="w"> </span>%esi<span class="w"> </span>from<span class="w"> </span>%ecx +shr<span class="w"> </span>%ecx<span class="w"> </span>//<span class="w"> </span>Right<span class="w"> </span><span class="nb">shift</span><span class="w"> </span>the<span class="w"> </span>value<span class="w"> </span><span class="k">in</span><span class="w"> </span>%ecx<span class="w"> </span>by<span class="w"> </span>one<span class="w"> </span>bit<span class="w"> </span><span class="o">(</span>dividing<span class="w"> </span>the<span class="w"> </span>value<span class="w"> </span>by<span class="w"> </span><span class="m">2</span><span class="o">)</span> +add<span class="w"> </span>%esi,%ecx<span class="w"> </span>//<span class="w"> </span>Add<span class="w"> </span>the<span class="w"> </span>value<span class="w"> </span><span class="k">in</span><span class="w"> </span>%esi<span class="w"> </span>to<span class="w"> </span>%ecx +cmp<span class="w"> </span>%edi,%ecx<span class="w"> </span>//<span class="w"> </span>Compare +ja<span class="w"> </span>0x5555555557b9<span class="w"> </span><func4+32><span class="w"> </span>//<span class="w"> </span>If<span class="w"> </span>%ecx<span class="w"> </span>><span class="w"> </span>%edi<span class="w"> </span>-><span class="w"> </span>jump<span class="w"> </span>to<span class="w"> </span>instruction<span class="w"> </span>at<span class="w"> </span>offset<span class="w"> </span>+32 +mov<span class="w"> </span><span class="nv">$0</span>x0,%eax<span class="w"> </span>//<span class="w"> </span>Move<span class="w"> </span><span class="m">0</span><span class="w"> </span>to<span class="w"> </span>%eax +jb<span class="w"> </span>0x5555555557c5<span class="w"> </span><func4+44><span class="w"> </span>//<span class="w"> </span>If<span class="w"> </span>%ecx<span class="w"> </span><<span class="w"> </span>%edi<span class="w"> </span>-><span class="w"> </span>jump<span class="w"> </span>to<span class="w"> </span>instruction<span class="w"> </span>at<span class="w"> </span>offset<span class="w"> </span>+44. +add<span class="w"> </span><span class="nv">$0</span>x8,%rsp<span class="w"> </span>//<span class="w"> </span>add<span class="w"> </span><span class="m">8</span><span class="w"> </span>bytes<span class="w"> </span>to<span class="w"> </span>the<span class="w"> </span>stack<span class="w"> </span>pointer +ret<span class="w"> </span>//<span class="w"> </span><span class="k">return</span> +lea<span class="w"> </span>-0x1<span class="o">(</span>%rcx<span class="o">)</span>,%edx<span class="w"> </span>//<span class="w"> </span>LEA<span class="w"> </span>of<span class="w"> </span><span class="nv">$rxc</span><span class="w"> </span>-<span class="w"> </span><span class="m">1</span><span class="w"> </span>into<span class="w"> </span><span class="nv">$edx</span> +call<span class="w"> </span>0x555555555799<span class="w"> </span><func4><span class="w"> </span>//<span class="w"> </span>Call<span class="w"> </span>itself +add<span class="w"> </span>%eax,%eax<span class="w"> </span>//<span class="w"> </span>Double<span class="w"> </span>the<span class="w"> </span>value<span class="w"> </span><span class="k">in</span><span class="w"> </span>%eax +jmp<span class="w"> </span>0x5555555557b4<span class="w"> </span><func4+27><span class="w"> </span>//<span class="w"> </span>jump<span class="w"> </span>to<span class="w"> </span>the<span class="w"> </span>instruction<span class="w"> </span>at<span class="w"> </span>offset<span class="w"> </span>+27 +lea<span class="w"> </span>0x1<span class="o">(</span>%rcx<span class="o">)</span>,%esi +call<span class="w"> </span>0x555555555799<span class="w"> </span><func4> +lea<span class="w"> </span>0x1<span class="o">(</span>%rax,%rax,1<span class="o">)</span>,%eax<span class="w"> </span>//<span class="w"> </span>LEA<span class="w"> </span>of<span class="w"> </span>%rax<span class="w"> </span>*<span class="w"> </span><span class="m">2</span><span class="w"> </span>+<span class="w"> </span><span class="m">1</span><span class="w"> </span>into<span class="w"> </span><span class="nv">$eax</span><span class="w"> </span> +jmp<span class="w"> </span>0x5555555557b4<span class="w"> </span><func4+27> </code></pre> </div> @@ -710,79 +719,80 @@ jmp 0x5555555557b4 <func4+27> <p>Okay, so we know that the number needed to be passed to <code>func4</code> is 5. But, what about the second digit?</p> -<p>If we go back to the code for <code><phase_4></code>, we can see that: - <div class="codehilite"> - <pre><span></span><code>0x000055555555581f <+76>: cmpl <span class="nv">$0</span>x2,0x8<span class="o">(</span>%rsp<span class="o">)</span> - 0x0000555555555824 <+81>: je 0x55555555582b <phase_4+88> - </code></pre> - </div></p> +<p>If we go back to the code for <code><phase_4></code>, we can see that:</p> + +<div class="codehilite"> +<pre><span></span><code><span class="w"> </span>0x000055555555581f<span class="w"> </span><+76>:<span class="w"> </span>cmpl<span class="w"> </span><span class="nv">$0</span>x2,0x8<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>0x0000555555555824<span class="w"> </span><+81>:<span class="w"> </span>je<span class="w"> </span>0x55555555582b<span class="w"> </span><phase_4+88> +</code></pre> +</div> <p>The value at <code>$rsp+8</code> should be equal to 2. So, let us try passing <code>5 2</code> as our input.</p> <div class="codehilite"> <pre><span></span><code>... -Phase <span class="m">1</span> defused. How about the next one? -That<span class="err">'</span>s number <span class="m">2</span>. Keep going! -Halfway there! -<span class="m">5</span> <span class="m">2</span> +Phase<span class="w"> </span><span class="m">1</span><span class="w"> </span>defused.<span class="w"> </span>How<span class="w"> </span>about<span class="w"> </span>the<span class="w"> </span>next<span class="w"> </span>one? +That<span class="err">'</span>s<span class="w"> </span>number<span class="w"> </span><span class="m">2</span>.<span class="w"> </span>Keep<span class="w"> </span>going! +Halfway<span class="w"> </span>there! +<span class="m">5</span><span class="w"> </span><span class="m">2</span> -Breakpoint <span class="m">1</span>, 0x00005555555557d3 <span class="k">in</span> phase_4 <span class="o">()</span> -<span class="o">(</span>gdb<span class="o">)</span> <span class="k">continue</span> +Breakpoint<span class="w"> </span><span class="m">1</span>,<span class="w"> </span>0x00005555555557d3<span class="w"> </span><span class="k">in</span><span class="w"> </span>phase_4<span class="w"> </span><span class="o">()</span> +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span><span class="k">continue</span> Continuing. -So you got that one. Try this one. +So<span class="w"> </span>you<span class="w"> </span>got<span class="w"> </span>that<span class="w"> </span>one.<span class="w"> </span>Try<span class="w"> </span>this<span class="w"> </span>one. </code></pre> </div> <h2>Phase 5</h2> <div class="codehilite"> -<pre><span></span><code>So you got that one. Try this one. -<span class="nb">test</span> string - -Breakpoint <span class="m">1</span>, 0x0000555555555830 <span class="k">in</span> phase_5 <span class="o">()</span> -<span class="o">(</span>gdb<span class="o">)</span> disas phase_5 -Dump of assembler code <span class="k">for</span> <span class="k">function</span> phase_5: -<span class="o">=</span>> 0x0000555555555830 <+0>: endbr64 - 0x0000555555555834 <+4>: push %rbx - 0x0000555555555835 <+5>: sub <span class="nv">$0</span>x10,%rsp - 0x0000555555555839 <+9>: mov %rdi,%rbx - 0x000055555555583c <+12>: call 0x555555555b10 <string_length> - 0x0000555555555841 <+17>: cmp <span class="nv">$0</span>x6,%eax - 0x0000555555555844 <+20>: jne 0x55555555588b <phase_5+91> - 0x0000555555555846 <+22>: mov <span class="nv">$0</span>x0,%eax - 0x000055555555584b <+27>: lea 0x199e<span class="o">(</span>%rip<span class="o">)</span>,%rcx <span class="c1"># 0x5555555571f0 <array.0></span> - 0x0000555555555852 <+34>: movzbl <span class="o">(</span>%rbx,%rax,1<span class="o">)</span>,%edx - 0x0000555555555856 <+38>: and <span class="nv">$0</span>xf,%edx - 0x0000555555555859 <+41>: movzbl <span class="o">(</span>%rcx,%rdx,1<span class="o">)</span>,%edx - 0x000055555555585d <+45>: mov %dl,0x9<span class="o">(</span>%rsp,%rax,1<span class="o">)</span> - 0x0000555555555861 <+49>: add <span class="nv">$0</span>x1,%rax - 0x0000555555555865 <+53>: cmp <span class="nv">$0</span>x6,%rax - 0x0000555555555869 <+57>: jne 0x555555555852 <phase_5+34> - 0x000055555555586b <+59>: movb <span class="nv">$0</span>x0,0xf<span class="o">(</span>%rsp<span class="o">)</span> - 0x0000555555555870 <+64>: lea 0x9<span class="o">(</span>%rsp<span class="o">)</span>,%rdi - 0x0000555555555875 <+69>: lea 0x1943<span class="o">(</span>%rip<span class="o">)</span>,%rsi <span class="c1"># 0x5555555571bf</span> - 0x000055555555587c <+76>: call 0x555555555b31 <strings_not_equal> - 0x0000555555555881 <+81>: <span class="nb">test</span> %eax,%eax - 0x0000555555555883 <+83>: jne 0x555555555892 <phase_5+98> - 0x0000555555555885 <+85>: add <span class="nv">$0</span>x10,%rsp - 0x0000555555555889 <+89>: pop %rbx - 0x000055555555588a <+90>: ret - 0x000055555555588b <+91>: call 0x555555555d4a <explode_bomb> - 0x0000555555555890 <+96>: jmp 0x555555555846 <phase_5+22> - 0x0000555555555892 <+98>: call 0x555555555d4a <explode_bomb> - 0x0000555555555897 <+103>: jmp 0x555555555885 <phase_5+85> -End of assembler dump. -<span class="o">(</span>gdb<span class="o">)</span> +<pre><span></span><code>So<span class="w"> </span>you<span class="w"> </span>got<span class="w"> </span>that<span class="w"> </span>one.<span class="w"> </span>Try<span class="w"> </span>this<span class="w"> </span>one. +<span class="nb">test</span><span class="w"> </span>string + +Breakpoint<span class="w"> </span><span class="m">1</span>,<span class="w"> </span>0x0000555555555830<span class="w"> </span><span class="k">in</span><span class="w"> </span>phase_5<span class="w"> </span><span class="o">()</span> +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span>disas<span class="w"> </span>phase_5 +Dump<span class="w"> </span>of<span class="w"> </span>assembler<span class="w"> </span>code<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="k">function</span><span class="w"> </span>phase_5: +<span class="o">=</span>><span class="w"> </span>0x0000555555555830<span class="w"> </span><+0>:<span class="w"> </span>endbr64<span class="w"> </span> +<span class="w"> </span>0x0000555555555834<span class="w"> </span><+4>:<span class="w"> </span>push<span class="w"> </span>%rbx +<span class="w"> </span>0x0000555555555835<span class="w"> </span><+5>:<span class="w"> </span>sub<span class="w"> </span><span class="nv">$0</span>x10,%rsp +<span class="w"> </span>0x0000555555555839<span class="w"> </span><+9>:<span class="w"> </span>mov<span class="w"> </span>%rdi,%rbx +<span class="w"> </span>0x000055555555583c<span class="w"> </span><+12>:<span class="w"> </span>call<span class="w"> </span>0x555555555b10<span class="w"> </span><string_length> +<span class="w"> </span>0x0000555555555841<span class="w"> </span><+17>:<span class="w"> </span>cmp<span class="w"> </span><span class="nv">$0</span>x6,%eax +<span class="w"> </span>0x0000555555555844<span class="w"> </span><+20>:<span class="w"> </span>jne<span class="w"> </span>0x55555555588b<span class="w"> </span><phase_5+91> +<span class="w"> </span>0x0000555555555846<span class="w"> </span><+22>:<span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x0,%eax +<span class="w"> </span>0x000055555555584b<span class="w"> </span><+27>:<span class="w"> </span>lea<span class="w"> </span>0x199e<span class="o">(</span>%rip<span class="o">)</span>,%rcx<span class="w"> </span><span class="c1"># 0x5555555571f0 <array.0></span> +<span class="w"> </span>0x0000555555555852<span class="w"> </span><+34>:<span class="w"> </span>movzbl<span class="w"> </span><span class="o">(</span>%rbx,%rax,1<span class="o">)</span>,%edx +<span class="w"> </span>0x0000555555555856<span class="w"> </span><+38>:<span class="w"> </span>and<span class="w"> </span><span class="nv">$0</span>xf,%edx +<span class="w"> </span>0x0000555555555859<span class="w"> </span><+41>:<span class="w"> </span>movzbl<span class="w"> </span><span class="o">(</span>%rcx,%rdx,1<span class="o">)</span>,%edx +<span class="w"> </span>0x000055555555585d<span class="w"> </span><+45>:<span class="w"> </span>mov<span class="w"> </span>%dl,0x9<span class="o">(</span>%rsp,%rax,1<span class="o">)</span> +<span class="w"> </span>0x0000555555555861<span class="w"> </span><+49>:<span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x1,%rax +<span class="w"> </span>0x0000555555555865<span class="w"> </span><+53>:<span class="w"> </span>cmp<span class="w"> </span><span class="nv">$0</span>x6,%rax +<span class="w"> </span>0x0000555555555869<span class="w"> </span><+57>:<span class="w"> </span>jne<span class="w"> </span>0x555555555852<span class="w"> </span><phase_5+34> +<span class="w"> </span>0x000055555555586b<span class="w"> </span><+59>:<span class="w"> </span>movb<span class="w"> </span><span class="nv">$0</span>x0,0xf<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>0x0000555555555870<span class="w"> </span><+64>:<span class="w"> </span>lea<span class="w"> </span>0x9<span class="o">(</span>%rsp<span class="o">)</span>,%rdi +<span class="w"> </span>0x0000555555555875<span class="w"> </span><+69>:<span class="w"> </span>lea<span class="w"> </span>0x1943<span class="o">(</span>%rip<span class="o">)</span>,%rsi<span class="w"> </span><span class="c1"># 0x5555555571bf</span> +<span class="w"> </span>0x000055555555587c<span class="w"> </span><+76>:<span class="w"> </span>call<span class="w"> </span>0x555555555b31<span class="w"> </span><strings_not_equal> +<span class="w"> </span>0x0000555555555881<span class="w"> </span><+81>:<span class="w"> </span><span class="nb">test</span><span class="w"> </span>%eax,%eax +<span class="w"> </span>0x0000555555555883<span class="w"> </span><+83>:<span class="w"> </span>jne<span class="w"> </span>0x555555555892<span class="w"> </span><phase_5+98> +<span class="w"> </span>0x0000555555555885<span class="w"> </span><+85>:<span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x10,%rsp +<span class="w"> </span>0x0000555555555889<span class="w"> </span><+89>:<span class="w"> </span>pop<span class="w"> </span>%rbx +<span class="w"> </span>0x000055555555588a<span class="w"> </span><+90>:<span class="w"> </span>ret<span class="w"> </span> +<span class="w"> </span>0x000055555555588b<span class="w"> </span><+91>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span>0x0000555555555890<span class="w"> </span><+96>:<span class="w"> </span>jmp<span class="w"> </span>0x555555555846<span class="w"> </span><phase_5+22> +<span class="w"> </span>0x0000555555555892<span class="w"> </span><+98>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span>0x0000555555555897<span class="w"> </span><+103>:<span class="w"> </span>jmp<span class="w"> </span>0x555555555885<span class="w"> </span><phase_5+85> +End<span class="w"> </span>of<span class="w"> </span>assembler<span class="w"> </span>dump. +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span> </code></pre> </div> <div class="codehilite"> <pre><span></span><code>... - 0x000055555555583c <+12>: call 0x555555555b10 <string_length> - 0x0000555555555841 <+17>: cmp <span class="nv">$0</span>x6,%eax - 0x0000555555555844 <+20>: jne 0x55555555588b <phase_5+91> +<span class="w"> </span>0x000055555555583c<span class="w"> </span><+12>:<span class="w"> </span>call<span class="w"> </span>0x555555555b10<span class="w"> </span><string_length> +<span class="w"> </span>0x0000555555555841<span class="w"> </span><+17>:<span class="w"> </span>cmp<span class="w"> </span><span class="nv">$0</span>x6,%eax +<span class="w"> </span>0x0000555555555844<span class="w"> </span><+20>:<span class="w"> </span>jne<span class="w"> </span>0x55555555588b<span class="w"> </span><phase_5+91> ... - 0x000055555555588b <+91>: call 0x555555555d4a <explode_bomb> +<span class="w"> </span>0x000055555555588b<span class="w"> </span><+91>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> ... </code></pre> </div> @@ -810,11 +820,11 @@ End of assembler dump. <p>We can check the reference string we need, which <code>gdb</code> has marked as <code># 0x5555555571bf</code>, and the lookup table marked as <code># 0x5555555571f0 <array.0></code></p> <div class="codehilite"> -<pre><span></span><code><span class="o">(</span>gdb<span class="o">)</span> x/s 0x5555555571bf -0x5555555571bf: <span class="s2">"bruins"</span> -<span class="o">(</span>gdb<span class="o">)</span> x/s 0x5555555571f0 -0x5555555571f0 <array.0>: <span class="s2">"maduiersnfotvbylSo you think you can stop the bomb with ctrl-c, do you?"</span> -<span class="o">(</span>gdb<span class="o">)</span> +<pre><span></span><code><span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span>x/s<span class="w"> </span>0x5555555571bf +0x5555555571bf:<span class="w"> </span><span class="s2">"bruins"</span> +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span>x/s<span class="w"> </span>0x5555555571f0 +0x5555555571f0<span class="w"> </span><array.0>:<span class="w"> </span><span class="s2">"maduiersnfotvbylSo you think you can stop the bomb with ctrl-c, do you?"</span> +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span> </code></pre> </div> @@ -850,15 +860,15 @@ s -> g <div class="codehilite"> <pre><span></span><code>... -That<span class="err">'</span>s number <span class="m">2</span>. Keep going! -Halfway there! -So you got that one. Try this one. +That<span class="err">'</span>s<span class="w"> </span>number<span class="w"> </span><span class="m">2</span>.<span class="w"> </span>Keep<span class="w"> </span>going! +Halfway<span class="w"> </span>there! +So<span class="w"> </span>you<span class="w"> </span>got<span class="w"> </span>that<span class="w"> </span>one.<span class="w"> </span>Try<span class="w"> </span>this<span class="w"> </span>one. mfcdhg -Breakpoint <span class="m">1</span>, 0x0000555555555830 <span class="k">in</span> phase_5 <span class="o">()</span> -<span class="o">(</span>gdb<span class="o">)</span> <span class="k">continue</span> +Breakpoint<span class="w"> </span><span class="m">1</span>,<span class="w"> </span>0x0000555555555830<span class="w"> </span><span class="k">in</span><span class="w"> </span>phase_5<span class="w"> </span><span class="o">()</span> +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span><span class="k">continue</span> Continuing. -Good work! On to the next... +Good<span class="w"> </span>work!<span class="w"> </span>On<span class="w"> </span>to<span class="w"> </span>the<span class="w"> </span>next... </code></pre> </div> @@ -867,122 +877,123 @@ Good work! On to the next... <h2>Phase 6</h2> <div class="codehilite"> -<pre><span></span><code>Good work! On to the next... -<span class="nb">test</span> string - -Breakpoint <span class="m">1</span>, 0x0000555555555899 <span class="k">in</span> phase_6 <span class="o">()</span> -<span class="o">(</span>gdb<span class="o">)</span> disas phase_6 -Dump of assembler code <span class="k">for</span> <span class="k">function</span> phase_6: -<span class="o">=</span>> 0x0000555555555899 <+0>: endbr64 - 0x000055555555589d <+4>: push %r15 - 0x000055555555589f <+6>: push %r14 - 0x00005555555558a1 <+8>: push %r13 - 0x00005555555558a3 <+10>: push %r12 - 0x00005555555558a5 <+12>: push %rbp - 0x00005555555558a6 <+13>: push %rbx - 0x00005555555558a7 <+14>: sub <span class="nv">$0</span>x68,%rsp - 0x00005555555558ab <+18>: lea 0x40<span class="o">(</span>%rsp<span class="o">)</span>,%rax - 0x00005555555558b0 <+23>: mov %rax,%r14 - 0x00005555555558b3 <+26>: mov %rax,0x8<span class="o">(</span>%rsp<span class="o">)</span> - 0x00005555555558b8 <+31>: mov %rax,%rsi - 0x00005555555558bb <+34>: call 0x555555555d97 <read_six_numbers> - 0x00005555555558c0 <+39>: mov %r14,%r12 - 0x00005555555558c3 <+42>: mov <span class="nv">$0</span>x1,%r15d - 0x00005555555558c9 <+48>: mov %r14,%r13 - 0x00005555555558cc <+51>: jmp 0x555555555997 <phase_6+254> - 0x00005555555558d1 <+56>: call 0x555555555d4a <explode_bomb> - 0x00005555555558d6 <+61>: jmp 0x5555555559a9 <phase_6+272> - 0x00005555555558db <+66>: add <span class="nv">$0</span>x1,%rbx - 0x00005555555558df <+70>: cmp <span class="nv">$0</span>x5,%ebx - 0x00005555555558e2 <+73>: jg 0x55555555598f <phase_6+246> - 0x00005555555558e8 <+79>: mov 0x0<span class="o">(</span>%r13,%rbx,4<span class="o">)</span>,%eax - 0x00005555555558ed <+84>: cmp %eax,0x0<span class="o">(</span>%rbp<span class="o">)</span> - 0x00005555555558f0 <+87>: jne 0x5555555558db <phase_6+66> - 0x00005555555558f2 <+89>: call 0x555555555d4a <explode_bomb> - 0x00005555555558f7 <+94>: jmp 0x5555555558db <phase_6+66> - 0x00005555555558f9 <+96>: mov 0x8<span class="o">(</span>%rsp<span class="o">)</span>,%rdx - 0x00005555555558fe <+101>: add <span class="nv">$0</span>x18,%rdx - 0x0000555555555902 <+105>: mov <span class="nv">$0</span>x7,%ecx - 0x0000555555555907 <+110>: mov %ecx,%eax - 0x0000555555555909 <+112>: sub <span class="o">(</span>%r12<span class="o">)</span>,%eax - 0x000055555555590d <+116>: mov %eax,<span class="o">(</span>%r12<span class="o">)</span> - 0x0000555555555911 <+120>: add <span class="nv">$0</span>x4,%r12 - 0x0000555555555915 <+124>: cmp %r12,%rdx - 0x0000555555555918 <+127>: jne 0x555555555907 <phase_6+110> - 0x000055555555591a <+129>: mov <span class="nv">$0</span>x0,%esi - 0x000055555555591f <+134>: mov 0x40<span class="o">(</span>%rsp,%rsi,4<span class="o">)</span>,%ecx - 0x0000555555555923 <+138>: mov <span class="nv">$0</span>x1,%eax - 0x0000555555555928 <+143>: lea 0x3d01<span class="o">(</span>%rip<span class="o">)</span>,%rdx <span class="c1"># 0x555555559630 <node1></span> ---Type <RET> <span class="k">for</span> more, q to quit, c to <span class="k">continue</span> without paging-- - 0x000055555555592f <+150>: cmp <span class="nv">$0</span>x1,%ecx - 0x0000555555555932 <+153>: jle 0x55555555593f <phase_6+166> - 0x0000555555555934 <+155>: mov 0x8<span class="o">(</span>%rdx<span class="o">)</span>,%rdx - 0x0000555555555938 <+159>: add <span class="nv">$0</span>x1,%eax - 0x000055555555593b <+162>: cmp %ecx,%eax - 0x000055555555593d <+164>: jne 0x555555555934 <phase_6+155> - 0x000055555555593f <+166>: mov %rdx,0x10<span class="o">(</span>%rsp,%rsi,8<span class="o">)</span> - 0x0000555555555944 <+171>: add <span class="nv">$0</span>x1,%rsi - 0x0000555555555948 <+175>: cmp <span class="nv">$0</span>x6,%rsi - 0x000055555555594c <+179>: jne 0x55555555591f <phase_6+134> - 0x000055555555594e <+181>: mov 0x10<span class="o">(</span>%rsp<span class="o">)</span>,%rbx - 0x0000555555555953 <+186>: mov 0x18<span class="o">(</span>%rsp<span class="o">)</span>,%rax - 0x0000555555555958 <+191>: mov %rax,0x8<span class="o">(</span>%rbx<span class="o">)</span> - 0x000055555555595c <+195>: mov 0x20<span class="o">(</span>%rsp<span class="o">)</span>,%rdx - 0x0000555555555961 <+200>: mov %rdx,0x8<span class="o">(</span>%rax<span class="o">)</span> - 0x0000555555555965 <+204>: mov 0x28<span class="o">(</span>%rsp<span class="o">)</span>,%rax - 0x000055555555596a <+209>: mov %rax,0x8<span class="o">(</span>%rdx<span class="o">)</span> - 0x000055555555596e <+213>: mov 0x30<span class="o">(</span>%rsp<span class="o">)</span>,%rdx - 0x0000555555555973 <+218>: mov %rdx,0x8<span class="o">(</span>%rax<span class="o">)</span> - 0x0000555555555977 <+222>: mov 0x38<span class="o">(</span>%rsp<span class="o">)</span>,%rax - 0x000055555555597c <+227>: mov %rax,0x8<span class="o">(</span>%rdx<span class="o">)</span> - 0x0000555555555980 <+231>: movq <span class="nv">$0</span>x0,0x8<span class="o">(</span>%rax<span class="o">)</span> - 0x0000555555555988 <+239>: mov <span class="nv">$0</span>x5,%ebp - 0x000055555555598d <+244>: jmp 0x5555555559c4 <phase_6+299> - 0x000055555555598f <+246>: add <span class="nv">$0</span>x1,%r15 - 0x0000555555555993 <+250>: add <span class="nv">$0</span>x4,%r14 - 0x0000555555555997 <+254>: mov %r14,%rbp - 0x000055555555599a <+257>: mov <span class="o">(</span>%r14<span class="o">)</span>,%eax - 0x000055555555599d <+260>: sub <span class="nv">$0</span>x1,%eax - 0x00005555555559a0 <+263>: cmp <span class="nv">$0</span>x5,%eax - 0x00005555555559a3 <+266>: ja 0x5555555558d1 <phase_6+56> - 0x00005555555559a9 <+272>: cmp <span class="nv">$0</span>x5,%r15d - 0x00005555555559ad <+276>: jg 0x5555555558f9 <phase_6+96> - 0x00005555555559b3 <+282>: mov %r15,%rbx - 0x00005555555559b6 <+285>: jmp 0x5555555558e8 <phase_6+79> - 0x00005555555559bb <+290>: mov 0x8<span class="o">(</span>%rbx<span class="o">)</span>,%rbx - 0x00005555555559bf <+294>: sub <span class="nv">$0</span>x1,%ebp - 0x00005555555559c2 <+297>: je 0x5555555559d5 <phase_6+316> - 0x00005555555559c4 <+299>: mov 0x8<span class="o">(</span>%rbx<span class="o">)</span>,%rax - 0x00005555555559c8 <+303>: mov <span class="o">(</span>%rax<span class="o">)</span>,%eax - 0x00005555555559ca <+305>: cmp %eax,<span class="o">(</span>%rbx<span class="o">)</span> ---Type <RET> <span class="k">for</span> more, q to quit, c to <span class="k">continue</span> without paging-- - 0x00005555555559cc <+307>: jge 0x5555555559bb <phase_6+290> - 0x00005555555559ce <+309>: call 0x555555555d4a <explode_bomb> - 0x00005555555559d3 <+314>: jmp 0x5555555559bb <phase_6+290> - 0x00005555555559d5 <+316>: add <span class="nv">$0</span>x68,%rsp - 0x00005555555559d9 <+320>: pop %rbx - 0x00005555555559da <+321>: pop %rbp - 0x00005555555559db <+322>: pop %r12 - 0x00005555555559dd <+324>: pop %r13 - 0x00005555555559df <+326>: pop %r14 - 0x00005555555559e1 <+328>: pop %r15 - 0x00005555555559e3 <+330>: ret -End of assembler dump. -<span class="o">(</span>gdb<span class="o">)</span> +<pre><span></span><code>Good<span class="w"> </span>work!<span class="w"> </span>On<span class="w"> </span>to<span class="w"> </span>the<span class="w"> </span>next... +<span class="nb">test</span><span class="w"> </span>string + +Breakpoint<span class="w"> </span><span class="m">1</span>,<span class="w"> </span>0x0000555555555899<span class="w"> </span><span class="k">in</span><span class="w"> </span>phase_6<span class="w"> </span><span class="o">()</span> +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span>disas<span class="w"> </span>phase_6 +Dump<span class="w"> </span>of<span class="w"> </span>assembler<span class="w"> </span>code<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="k">function</span><span class="w"> </span>phase_6: +<span class="o">=</span>><span class="w"> </span>0x0000555555555899<span class="w"> </span><+0>:<span class="w"> </span>endbr64<span class="w"> </span> +<span class="w"> </span>0x000055555555589d<span class="w"> </span><+4>:<span class="w"> </span>push<span class="w"> </span>%r15 +<span class="w"> </span>0x000055555555589f<span class="w"> </span><+6>:<span class="w"> </span>push<span class="w"> </span>%r14 +<span class="w"> </span>0x00005555555558a1<span class="w"> </span><+8>:<span class="w"> </span>push<span class="w"> </span>%r13 +<span class="w"> </span>0x00005555555558a3<span class="w"> </span><+10>:<span class="w"> </span>push<span class="w"> </span>%r12 +<span class="w"> </span>0x00005555555558a5<span class="w"> </span><+12>:<span class="w"> </span>push<span class="w"> </span>%rbp +<span class="w"> </span>0x00005555555558a6<span class="w"> </span><+13>:<span class="w"> </span>push<span class="w"> </span>%rbx +<span class="w"> </span>0x00005555555558a7<span class="w"> </span><+14>:<span class="w"> </span>sub<span class="w"> </span><span class="nv">$0</span>x68,%rsp +<span class="w"> </span>0x00005555555558ab<span class="w"> </span><+18>:<span class="w"> </span>lea<span class="w"> </span>0x40<span class="o">(</span>%rsp<span class="o">)</span>,%rax +<span class="w"> </span>0x00005555555558b0<span class="w"> </span><+23>:<span class="w"> </span>mov<span class="w"> </span>%rax,%r14 +<span class="w"> </span>0x00005555555558b3<span class="w"> </span><+26>:<span class="w"> </span>mov<span class="w"> </span>%rax,0x8<span class="o">(</span>%rsp<span class="o">)</span> +<span class="w"> </span>0x00005555555558b8<span class="w"> </span><+31>:<span class="w"> </span>mov<span class="w"> </span>%rax,%rsi +<span class="w"> </span>0x00005555555558bb<span class="w"> </span><+34>:<span class="w"> </span>call<span class="w"> </span>0x555555555d97<span class="w"> </span><read_six_numbers> +<span class="w"> </span>0x00005555555558c0<span class="w"> </span><+39>:<span class="w"> </span>mov<span class="w"> </span>%r14,%r12 +<span class="w"> </span>0x00005555555558c3<span class="w"> </span><+42>:<span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x1,%r15d +<span class="w"> </span>0x00005555555558c9<span class="w"> </span><+48>:<span class="w"> </span>mov<span class="w"> </span>%r14,%r13 +<span class="w"> </span>0x00005555555558cc<span class="w"> </span><+51>:<span class="w"> </span>jmp<span class="w"> </span>0x555555555997<span class="w"> </span><phase_6+254> +<span class="w"> </span>0x00005555555558d1<span class="w"> </span><+56>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span>0x00005555555558d6<span class="w"> </span><+61>:<span class="w"> </span>jmp<span class="w"> </span>0x5555555559a9<span class="w"> </span><phase_6+272> +<span class="w"> </span>0x00005555555558db<span class="w"> </span><+66>:<span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x1,%rbx +<span class="w"> </span>0x00005555555558df<span class="w"> </span><+70>:<span class="w"> </span>cmp<span class="w"> </span><span class="nv">$0</span>x5,%ebx +<span class="w"> </span>0x00005555555558e2<span class="w"> </span><+73>:<span class="w"> </span>jg<span class="w"> </span>0x55555555598f<span class="w"> </span><phase_6+246> +<span class="w"> </span>0x00005555555558e8<span class="w"> </span><+79>:<span class="w"> </span>mov<span class="w"> </span>0x0<span class="o">(</span>%r13,%rbx,4<span class="o">)</span>,%eax +<span class="w"> </span>0x00005555555558ed<span class="w"> </span><+84>:<span class="w"> </span>cmp<span class="w"> </span>%eax,0x0<span class="o">(</span>%rbp<span class="o">)</span> +<span class="w"> </span>0x00005555555558f0<span class="w"> </span><+87>:<span class="w"> </span>jne<span class="w"> </span>0x5555555558db<span class="w"> </span><phase_6+66> +<span class="w"> </span>0x00005555555558f2<span class="w"> </span><+89>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span>0x00005555555558f7<span class="w"> </span><+94>:<span class="w"> </span>jmp<span class="w"> </span>0x5555555558db<span class="w"> </span><phase_6+66> +<span class="w"> </span>0x00005555555558f9<span class="w"> </span><+96>:<span class="w"> </span>mov<span class="w"> </span>0x8<span class="o">(</span>%rsp<span class="o">)</span>,%rdx +<span class="w"> </span>0x00005555555558fe<span class="w"> </span><+101>:<span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x18,%rdx +<span class="w"> </span>0x0000555555555902<span class="w"> </span><+105>:<span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x7,%ecx +<span class="w"> </span>0x0000555555555907<span class="w"> </span><+110>:<span class="w"> </span>mov<span class="w"> </span>%ecx,%eax +<span class="w"> </span>0x0000555555555909<span class="w"> </span><+112>:<span class="w"> </span>sub<span class="w"> </span><span class="o">(</span>%r12<span class="o">)</span>,%eax +<span class="w"> </span>0x000055555555590d<span class="w"> </span><+116>:<span class="w"> </span>mov<span class="w"> </span>%eax,<span class="o">(</span>%r12<span class="o">)</span> +<span class="w"> </span>0x0000555555555911<span class="w"> </span><+120>:<span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x4,%r12 +<span class="w"> </span>0x0000555555555915<span class="w"> </span><+124>:<span class="w"> </span>cmp<span class="w"> </span>%r12,%rdx +<span class="w"> </span>0x0000555555555918<span class="w"> </span><+127>:<span class="w"> </span>jne<span class="w"> </span>0x555555555907<span class="w"> </span><phase_6+110> +<span class="w"> </span>0x000055555555591a<span class="w"> </span><+129>:<span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x0,%esi +<span class="w"> </span>0x000055555555591f<span class="w"> </span><+134>:<span class="w"> </span>mov<span class="w"> </span>0x40<span class="o">(</span>%rsp,%rsi,4<span class="o">)</span>,%ecx +<span class="w"> </span>0x0000555555555923<span class="w"> </span><+138>:<span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x1,%eax +<span class="w"> </span>0x0000555555555928<span class="w"> </span><+143>:<span class="w"> </span>lea<span class="w"> </span>0x3d01<span class="o">(</span>%rip<span class="o">)</span>,%rdx<span class="w"> </span><span class="c1"># 0x555555559630 <node1></span> +--Type<span class="w"> </span><RET><span class="w"> </span><span class="k">for</span><span class="w"> </span>more,<span class="w"> </span>q<span class="w"> </span>to<span class="w"> </span>quit,<span class="w"> </span>c<span class="w"> </span>to<span class="w"> </span><span class="k">continue</span><span class="w"> </span>without<span class="w"> </span>paging-- +<span class="w"> </span>0x000055555555592f<span class="w"> </span><+150>:<span class="w"> </span>cmp<span class="w"> </span><span class="nv">$0</span>x1,%ecx +<span class="w"> </span>0x0000555555555932<span class="w"> </span><+153>:<span class="w"> </span>jle<span class="w"> </span>0x55555555593f<span class="w"> </span><phase_6+166> +<span class="w"> </span>0x0000555555555934<span class="w"> </span><+155>:<span class="w"> </span>mov<span class="w"> </span>0x8<span class="o">(</span>%rdx<span class="o">)</span>,%rdx +<span class="w"> </span>0x0000555555555938<span class="w"> </span><+159>:<span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x1,%eax +<span class="w"> </span>0x000055555555593b<span class="w"> </span><+162>:<span class="w"> </span>cmp<span class="w"> </span>%ecx,%eax +<span class="w"> </span>0x000055555555593d<span class="w"> </span><+164>:<span class="w"> </span>jne<span class="w"> </span>0x555555555934<span class="w"> </span><phase_6+155> +<span class="w"> </span>0x000055555555593f<span class="w"> </span><+166>:<span class="w"> </span>mov<span class="w"> </span>%rdx,0x10<span class="o">(</span>%rsp,%rsi,8<span class="o">)</span> +<span class="w"> </span>0x0000555555555944<span class="w"> </span><+171>:<span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x1,%rsi +<span class="w"> </span>0x0000555555555948<span class="w"> </span><+175>:<span class="w"> </span>cmp<span class="w"> </span><span class="nv">$0</span>x6,%rsi +<span class="w"> </span>0x000055555555594c<span class="w"> </span><+179>:<span class="w"> </span>jne<span class="w"> </span>0x55555555591f<span class="w"> </span><phase_6+134> +<span class="w"> </span>0x000055555555594e<span class="w"> </span><+181>:<span class="w"> </span>mov<span class="w"> </span>0x10<span class="o">(</span>%rsp<span class="o">)</span>,%rbx +<span class="w"> </span>0x0000555555555953<span class="w"> </span><+186>:<span class="w"> </span>mov<span class="w"> </span>0x18<span class="o">(</span>%rsp<span class="o">)</span>,%rax +<span class="w"> </span>0x0000555555555958<span class="w"> </span><+191>:<span class="w"> </span>mov<span class="w"> </span>%rax,0x8<span class="o">(</span>%rbx<span class="o">)</span> +<span class="w"> </span>0x000055555555595c<span class="w"> </span><+195>:<span class="w"> </span>mov<span class="w"> </span>0x20<span class="o">(</span>%rsp<span class="o">)</span>,%rdx +<span class="w"> </span>0x0000555555555961<span class="w"> </span><+200>:<span class="w"> </span>mov<span class="w"> </span>%rdx,0x8<span class="o">(</span>%rax<span class="o">)</span> +<span class="w"> </span>0x0000555555555965<span class="w"> </span><+204>:<span class="w"> </span>mov<span class="w"> </span>0x28<span class="o">(</span>%rsp<span class="o">)</span>,%rax +<span class="w"> </span>0x000055555555596a<span class="w"> </span><+209>:<span class="w"> </span>mov<span class="w"> </span>%rax,0x8<span class="o">(</span>%rdx<span class="o">)</span> +<span class="w"> </span>0x000055555555596e<span class="w"> </span><+213>:<span class="w"> </span>mov<span class="w"> </span>0x30<span class="o">(</span>%rsp<span class="o">)</span>,%rdx +<span class="w"> </span>0x0000555555555973<span class="w"> </span><+218>:<span class="w"> </span>mov<span class="w"> </span>%rdx,0x8<span class="o">(</span>%rax<span class="o">)</span> +<span class="w"> </span>0x0000555555555977<span class="w"> </span><+222>:<span class="w"> </span>mov<span class="w"> </span>0x38<span class="o">(</span>%rsp<span class="o">)</span>,%rax +<span class="w"> </span>0x000055555555597c<span class="w"> </span><+227>:<span class="w"> </span>mov<span class="w"> </span>%rax,0x8<span class="o">(</span>%rdx<span class="o">)</span> +<span class="w"> </span>0x0000555555555980<span class="w"> </span><+231>:<span class="w"> </span>movq<span class="w"> </span><span class="nv">$0</span>x0,0x8<span class="o">(</span>%rax<span class="o">)</span> +<span class="w"> </span>0x0000555555555988<span class="w"> </span><+239>:<span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x5,%ebp +<span class="w"> </span>0x000055555555598d<span class="w"> </span><+244>:<span class="w"> </span>jmp<span class="w"> </span>0x5555555559c4<span class="w"> </span><phase_6+299> +<span class="w"> </span>0x000055555555598f<span class="w"> </span><+246>:<span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x1,%r15 +<span class="w"> </span>0x0000555555555993<span class="w"> </span><+250>:<span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x4,%r14 +<span class="w"> </span>0x0000555555555997<span class="w"> </span><+254>:<span class="w"> </span>mov<span class="w"> </span>%r14,%rbp +<span class="w"> </span>0x000055555555599a<span class="w"> </span><+257>:<span class="w"> </span>mov<span class="w"> </span><span class="o">(</span>%r14<span class="o">)</span>,%eax +<span class="w"> </span>0x000055555555599d<span class="w"> </span><+260>:<span class="w"> </span>sub<span class="w"> </span><span class="nv">$0</span>x1,%eax +<span class="w"> </span>0x00005555555559a0<span class="w"> </span><+263>:<span class="w"> </span>cmp<span class="w"> </span><span class="nv">$0</span>x5,%eax +<span class="w"> </span>0x00005555555559a3<span class="w"> </span><+266>:<span class="w"> </span>ja<span class="w"> </span>0x5555555558d1<span class="w"> </span><phase_6+56> +<span class="w"> </span>0x00005555555559a9<span class="w"> </span><+272>:<span class="w"> </span>cmp<span class="w"> </span><span class="nv">$0</span>x5,%r15d +<span class="w"> </span>0x00005555555559ad<span class="w"> </span><+276>:<span class="w"> </span>jg<span class="w"> </span>0x5555555558f9<span class="w"> </span><phase_6+96> +<span class="w"> </span>0x00005555555559b3<span class="w"> </span><+282>:<span class="w"> </span>mov<span class="w"> </span>%r15,%rbx +<span class="w"> </span>0x00005555555559b6<span class="w"> </span><+285>:<span class="w"> </span>jmp<span class="w"> </span>0x5555555558e8<span class="w"> </span><phase_6+79> +<span class="w"> </span>0x00005555555559bb<span class="w"> </span><+290>:<span class="w"> </span>mov<span class="w"> </span>0x8<span class="o">(</span>%rbx<span class="o">)</span>,%rbx +<span class="w"> </span>0x00005555555559bf<span class="w"> </span><+294>:<span class="w"> </span>sub<span class="w"> </span><span class="nv">$0</span>x1,%ebp +<span class="w"> </span>0x00005555555559c2<span class="w"> </span><+297>:<span class="w"> </span>je<span class="w"> </span>0x5555555559d5<span class="w"> </span><phase_6+316> +<span class="w"> </span>0x00005555555559c4<span class="w"> </span><+299>:<span class="w"> </span>mov<span class="w"> </span>0x8<span class="o">(</span>%rbx<span class="o">)</span>,%rax +<span class="w"> </span>0x00005555555559c8<span class="w"> </span><+303>:<span class="w"> </span>mov<span class="w"> </span><span class="o">(</span>%rax<span class="o">)</span>,%eax +<span class="w"> </span>0x00005555555559ca<span class="w"> </span><+305>:<span class="w"> </span>cmp<span class="w"> </span>%eax,<span class="o">(</span>%rbx<span class="o">)</span> +--Type<span class="w"> </span><RET><span class="w"> </span><span class="k">for</span><span class="w"> </span>more,<span class="w"> </span>q<span class="w"> </span>to<span class="w"> </span>quit,<span class="w"> </span>c<span class="w"> </span>to<span class="w"> </span><span class="k">continue</span><span class="w"> </span>without<span class="w"> </span>paging-- +<span class="w"> </span>0x00005555555559cc<span class="w"> </span><+307>:<span class="w"> </span>jge<span class="w"> </span>0x5555555559bb<span class="w"> </span><phase_6+290> +<span class="w"> </span>0x00005555555559ce<span class="w"> </span><+309>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span>0x00005555555559d3<span class="w"> </span><+314>:<span class="w"> </span>jmp<span class="w"> </span>0x5555555559bb<span class="w"> </span><phase_6+290> +<span class="w"> </span>0x00005555555559d5<span class="w"> </span><+316>:<span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x68,%rsp +<span class="w"> </span>0x00005555555559d9<span class="w"> </span><+320>:<span class="w"> </span>pop<span class="w"> </span>%rbx +<span class="w"> </span>0x00005555555559da<span class="w"> </span><+321>:<span class="w"> </span>pop<span class="w"> </span>%rbp +<span class="w"> </span>0x00005555555559db<span class="w"> </span><+322>:<span class="w"> </span>pop<span class="w"> </span>%r12 +<span class="w"> </span>0x00005555555559dd<span class="w"> </span><+324>:<span class="w"> </span>pop<span class="w"> </span>%r13 +<span class="w"> </span>0x00005555555559df<span class="w"> </span><+326>:<span class="w"> </span>pop<span class="w"> </span>%r14 +<span class="w"> </span>0x00005555555559e1<span class="w"> </span><+328>:<span class="w"> </span>pop<span class="w"> </span>%r15 +<span class="w"> </span>0x00005555555559e3<span class="w"> </span><+330>:<span class="w"> </span>ret<span class="w"> </span> +End<span class="w"> </span>of<span class="w"> </span>assembler<span class="w"> </span>dump. +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span> </code></pre> </div> <p>Again, we see the familiar <code>read_six_digits</code> function.</p> -<p>Let us analyse this function in chunks: - <div class="codehilite"> - <pre><span></span><code>0x00005555555558bb <+34>: call 0x555555555d97 <read<em>six</em>numbers> - 0x00005555555558c0 <+39>: mov %r14,%r12 - 0x00005555555558c3 <+42>: mov <span class="nv">$0</span>x1,%r15d - 0x00005555555558c9 <+48>: mov %r14,%r13 - 0x00005555555558cc <+51>: jmp 0x555555555997 <phase_6+254> - </code></pre> - </div></p> +<p>Let us analyse this function in chunks:</p> + +<div class="codehilite"> +<pre><span></span><code><span class="w"> </span>0x00005555555558bb<span class="w"> </span><+34>:<span class="w"> </span>call<span class="w"> </span>0x555555555d97<span class="w"> </span><read_six_numbers> +<span class="w"> </span>0x00005555555558c0<span class="w"> </span><+39>:<span class="w"> </span>mov<span class="w"> </span>%r14,%r12 +<span class="w"> </span>0x00005555555558c3<span class="w"> </span><+42>:<span class="w"> </span>mov<span class="w"> </span><span class="nv">$0</span>x1,%r15d +<span class="w"> </span>0x00005555555558c9<span class="w"> </span><+48>:<span class="w"> </span>mov<span class="w"> </span>%r14,%r13 +<span class="w"> </span>0x00005555555558cc<span class="w"> </span><+51>:<span class="w"> </span>jmp<span class="w"> </span>0x555555555997<span class="w"> </span><phase_6+254> +</code></pre> +</div> <ol> <li>Read six numbers</li> @@ -990,17 +1001,20 @@ End of assembler dump. 2.1. <code>mov %r14,%r12</code>: <code>%r14</code> should be pointing to the location of the stack where the numbers were read into. This address is copied onto <code>%r12</code> 2.2. <code>mov $0x1,%r15d</code>: The value <code>1</code> is moved into <code>%r15</code> register (probably acting like a counter) 2.3. <code>mov %r14,%r13</code>: The value is also copied to <code>%r13</code></li> -<li><p>Jump to start of loop:</p> +<li>Jump to start of loop:</li> +</ol> <div class="codehilite"> -<pre><span></span><code>0x0000555555555997 <+254>: mov %r14,%rbp -0x000055555555599a <+257>: mov <span class="o">(</span>%r14<span class="o">)</span>,%eax -0x000055555555599d <+260>: sub <span class="nv">$0</span>x1,%eax -0x00005555555559a0 <+263>: cmp <span class="nv">$0</span>x5,%eax -0x00005555555559a3 <+266>: ja 0x5555555558d1 <phase_6+56> +<pre><span></span><code><span class="w"> </span>0x0000555555555997<span class="w"> </span><+254>:<span class="w"> </span>mov<span class="w"> </span>%r14,%rbp +<span class="w"> </span>0x000055555555599a<span class="w"> </span><+257>:<span class="w"> </span>mov<span class="w"> </span><span class="o">(</span>%r14<span class="o">)</span>,%eax +<span class="w"> </span>0x000055555555599d<span class="w"> </span><+260>:<span class="w"> </span>sub<span class="w"> </span><span class="nv">$0</span>x1,%eax +<span class="w"> </span>0x00005555555559a0<span class="w"> </span><+263>:<span class="w"> </span>cmp<span class="w"> </span><span class="nv">$0</span>x5,%eax +<span class="w"> </span>0x00005555555559a3<span class="w"> </span><+266>:<span class="w"> </span>ja<span class="w"> </span>0x5555555558d1<span class="w"> </span><phase_6+56> </code></pre> -</div></li> -<li><p>Initialise register and point to first number in sequence</p></li> +</div> + +<ol> +<li>Initialise register and point to first number in sequence</li> <li>Adjust number(s): 2.1. <code>mov (%r14),%eax</code> -> load the current number in the sequence 2.2. <code>sub $0x1,%eax</code> -> decrement number by 1</li> @@ -1009,40 +1023,44 @@ End of assembler dump. 3.2. <code>ja 0x5555555558d1 <phase_6+56></code>: jump if given value is > 5 or < 0</li> </ol> -<p>=> All numbers should be between 1 and 6. - <div class="codehilite"> - <pre><span></span><code>0x00005555555559a9 <+272>: cmp <span class="nv">$0</span>x5,%r15d - 0x00005555555559ad <+276>: jg 0x5555555558f9 <phase_6+96> - </code></pre> - </div></p> - -<p>This checks if the value stored in <code>%r15</code> is > 5, if it is then it jumps somewhere else. This validates our assumption that <code>%r15</code> is acting as a counter. - <div class="codehilite"> - <pre><span></span><code>0x00005555555559b3 <+282>: mov %r15,%rbx - 0x00005555555559b6 <+285>: jmp 0x5555555558e8 <phase_6+79> - </code></pre> - </div></p> - -<p>Let us jump to +79 - <div class="codehilite"> - <pre><span></span><code>0x00005555555558e8 <+79>: mov 0x0<span class="o">(</span>%r13,%rbx,4<span class="o">)</span>,%eax - 0x00005555555558ed <+84>: cmp %eax,0x0<span class="o">(</span>%rbp<span class="o">)</span> - 0x00005555555558f0 <+87>: jne 0x5555555558db <phase<em>6+66> - 0x00005555555558f2 <+89>: call 0x555555555d4a <explode</em>bomb> - 0x00005555555558f7 <+94>: jmp 0x5555555558db <phase_6+66> - </code></pre> - </div></p> - -<p>This section deals with checking if all the numbers in the sequence are unique or not. Thus, we need to ensure out 6 digits are unique - <div class="codehilite"> - <pre><span></span><code>0x00005555555558db <+66>: add <span class="nv">$0</span>x1,%rbx // Increments by <span class="m">1</span> - 0x00005555555558df <+70>: cmp <span class="nv">$0</span>x5,%ebx - 0x00005555555558e2 <+73>: jg 0x55555555598f <phase<em>6+246> // Jump <span class="k">if</span> > <span class="m">5</span> <span class="o">(</span>Loop iterations are <span class="nb">complete</span><span class="o">)</span> - 0x00005555555558e8 <+79>: mov 0x0<span class="o">(</span>%r13,%rbx,4<span class="o">)</span>,%eax - 0x00005555555558ed <+84>: cmp %eax,0x0<span class="o">(</span>%rbp<span class="o">)</span> - 0x00005555555558f0 <+87>: jne 0x5555555558db <phase</em>6+66> // Again, check <span class="k">if</span> the number being seen is unique - </code></pre> - </div></p> +<p>=> All numbers should be between 1 and 6.</p> + +<div class="codehilite"> +<pre><span></span><code><span class="w"> </span>0x00005555555559a9<span class="w"> </span><+272>:<span class="w"> </span>cmp<span class="w"> </span><span class="nv">$0</span>x5,%r15d +<span class="w"> </span>0x00005555555559ad<span class="w"> </span><+276>:<span class="w"> </span>jg<span class="w"> </span>0x5555555558f9<span class="w"> </span><phase_6+96> +</code></pre> +</div> + +<p>This checks if the value stored in <code>%r15</code> is > 5, if it is then it jumps somewhere else. This validates our assumption that <code>%r15</code> is acting as a counter.</p> + +<div class="codehilite"> +<pre><span></span><code><span class="w"> </span>0x00005555555559b3<span class="w"> </span><+282>:<span class="w"> </span>mov<span class="w"> </span>%r15,%rbx +<span class="w"> </span>0x00005555555559b6<span class="w"> </span><+285>:<span class="w"> </span>jmp<span class="w"> </span>0x5555555558e8<span class="w"> </span><phase_6+79> +</code></pre> +</div> + +<p>Let us jump to +79</p> + +<div class="codehilite"> +<pre><span></span><code><span class="w"> </span>0x00005555555558e8<span class="w"> </span><+79>:<span class="w"> </span>mov<span class="w"> </span>0x0<span class="o">(</span>%r13,%rbx,4<span class="o">)</span>,%eax +<span class="w"> </span>0x00005555555558ed<span class="w"> </span><+84>:<span class="w"> </span>cmp<span class="w"> </span>%eax,0x0<span class="o">(</span>%rbp<span class="o">)</span> +<span class="w"> </span>0x00005555555558f0<span class="w"> </span><+87>:<span class="w"> </span>jne<span class="w"> </span>0x5555555558db<span class="w"> </span><phase_6+66> +<span class="w"> </span>0x00005555555558f2<span class="w"> </span><+89>:<span class="w"> </span>call<span class="w"> </span>0x555555555d4a<span class="w"> </span><explode_bomb> +<span class="w"> </span>0x00005555555558f7<span class="w"> </span><+94>:<span class="w"> </span>jmp<span class="w"> </span>0x5555555558db<span class="w"> </span><phase_6+66> +</code></pre> +</div> + +<p>This section deals with checking if all the numbers in the sequence are unique or not. Thus, we need to ensure out 6 digits are unique</p> + +<div class="codehilite"> +<pre><span></span><code><span class="w"> </span>0x00005555555558db<span class="w"> </span><+66>:<span class="w"> </span>add<span class="w"> </span><span class="nv">$0</span>x1,%rbx<span class="w"> </span>//<span class="w"> </span>Increments<span class="w"> </span>by<span class="w"> </span><span class="m">1</span> +<span class="w"> </span>0x00005555555558df<span class="w"> </span><+70>:<span class="w"> </span>cmp<span class="w"> </span><span class="nv">$0</span>x5,%ebx<span class="w"> </span> +<span class="w"> </span>0x00005555555558e2<span class="w"> </span><+73>:<span class="w"> </span>jg<span class="w"> </span>0x55555555598f<span class="w"> </span><phase_6+246><span class="w"> </span>//<span class="w"> </span>Jump<span class="w"> </span><span class="k">if</span><span class="w"> </span>><span class="w"> </span><span class="m">5</span><span class="w"> </span><span class="o">(</span>Loop<span class="w"> </span>iterations<span class="w"> </span>are<span class="w"> </span><span class="nb">complete</span><span class="o">)</span> +<span class="w"> </span>0x00005555555558e8<span class="w"> </span><+79>:<span class="w"> </span>mov<span class="w"> </span>0x0<span class="o">(</span>%r13,%rbx,4<span class="o">)</span>,%eax<span class="w"> </span> +<span class="w"> </span>0x00005555555558ed<span class="w"> </span><+84>:<span class="w"> </span>cmp<span class="w"> </span>%eax,0x0<span class="o">(</span>%rbp<span class="o">)</span> +<span class="w"> </span>0x00005555555558f0<span class="w"> </span><+87>:<span class="w"> </span>jne<span class="w"> </span>0x5555555558db<span class="w"> </span><phase_6+66><span class="w"> </span>//<span class="w"> </span>Again,<span class="w"> </span>check<span class="w"> </span><span class="k">if</span><span class="w"> </span>the<span class="w"> </span>number<span class="w"> </span>being<span class="w"> </span>seen<span class="w"> </span>is<span class="w"> </span>unique +</code></pre> +</div> <p>Now we know that the numbers are unique, between 1-6 (inclusive).</p> @@ -1053,36 +1071,36 @@ End of assembler dump. <p>Let us try to figure out what <code>0x0000555555555928 <+143>: lea 0x3d01(%rip),%rdx # 0x555555559630 <node1></code> is:</p> <div class="codehilite"> -<pre><span></span><code><span class="o">(</span>gdb<span class="o">)</span> x/30wx 0x555555559630 -0x555555559630 <node1>: 0x000000d9 0x00000001 0x55559640 0x00005555 -0x555555559640 <node2>: 0x000003ab 0x00000002 0x55559650 0x00005555 -0x555555559650 <node3>: 0x0000014f 0x00000003 0x55559660 0x00005555 -0x555555559660 <node4>: 0x000000a1 0x00000004 0x55559670 0x00005555 -0x555555559670 <node5>: 0x000001b3 0x00000005 0x55559120 0x00005555 -0x555555559680 <host_table>: 0x555573f5 0x00005555 0x5555740f 0x00005555 -0x555555559690 <host_table+16>: 0x55557429 0x00005555 0x00000000 0x00000000 -0x5555555596a0 <host_table+32>: 0x00000000 0x00000000 -<span class="o">(</span>gdb<span class="o">)</span> x/30wx 0x555555559120 -0x555555559120 <node6>: 0x000002da 0x00000006 0x00000000 0x00000000 -0x555555559130: 0x00000000 0x00000000 0x00000000 0x00000000 -0x555555559140 <userid>: 0x61767861 0x38383535 0x00000000 0x00000000 -0x555555559150 <userid+16>: 0x00000000 0x00000000 0x00000000 0x00000000 -0x555555559160 <userid+32>: 0x00000000 0x00000000 0x00000000 0x00000000 -0x555555559170 <userid+48>: 0x00000000 0x00000000 0x00000000 0x00000000 -0x555555559180 <userid+64>: 0x00000000 0x00000000 0x00000000 0x00000000 -0x555555559190 <userid+80>: 0x00000000 0x00000000 -<span class="o">(</span>gdb<span class="o">)</span> +<pre><span></span><code><span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span>x/30wx<span class="w"> </span>0x555555559630 +0x555555559630<span class="w"> </span><node1>:<span class="w"> </span>0x000000d9<span class="w"> </span>0x00000001<span class="w"> </span>0x55559640<span class="w"> </span>0x00005555 +0x555555559640<span class="w"> </span><node2>:<span class="w"> </span>0x000003ab<span class="w"> </span>0x00000002<span class="w"> </span>0x55559650<span class="w"> </span>0x00005555 +0x555555559650<span class="w"> </span><node3>:<span class="w"> </span>0x0000014f<span class="w"> </span>0x00000003<span class="w"> </span>0x55559660<span class="w"> </span>0x00005555 +0x555555559660<span class="w"> </span><node4>:<span class="w"> </span>0x000000a1<span class="w"> </span>0x00000004<span class="w"> </span>0x55559670<span class="w"> </span>0x00005555 +0x555555559670<span class="w"> </span><node5>:<span class="w"> </span>0x000001b3<span class="w"> </span>0x00000005<span class="w"> </span>0x55559120<span class="w"> </span>0x00005555 +0x555555559680<span class="w"> </span><host_table>:<span class="w"> </span>0x555573f5<span class="w"> </span>0x00005555<span class="w"> </span>0x5555740f<span class="w"> </span>0x00005555 +0x555555559690<span class="w"> </span><host_table+16>:<span class="w"> </span>0x55557429<span class="w"> </span>0x00005555<span class="w"> </span>0x00000000<span class="w"> </span>0x00000000 +0x5555555596a0<span class="w"> </span><host_table+32>:<span class="w"> </span>0x00000000<span class="w"> </span>0x00000000 +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span>x/30wx<span class="w"> </span>0x555555559120 +0x555555559120<span class="w"> </span><node6>:<span class="w"> </span>0x000002da<span class="w"> </span>0x00000006<span class="w"> </span>0x00000000<span class="w"> </span>0x00000000 +0x555555559130:<span class="w"> </span>0x00000000<span class="w"> </span>0x00000000<span class="w"> </span>0x00000000<span class="w"> </span>0x00000000 +0x555555559140<span class="w"> </span><userid>:<span class="w"> </span>0x61767861<span class="w"> </span>0x38383535<span class="w"> </span>0x00000000<span class="w"> </span>0x00000000 +0x555555559150<span class="w"> </span><userid+16>:<span class="w"> </span>0x00000000<span class="w"> </span>0x00000000<span class="w"> </span>0x00000000<span class="w"> </span>0x00000000 +0x555555559160<span class="w"> </span><userid+32>:<span class="w"> </span>0x00000000<span class="w"> </span>0x00000000<span class="w"> </span>0x00000000<span class="w"> </span>0x00000000 +0x555555559170<span class="w"> </span><userid+48>:<span class="w"> </span>0x00000000<span class="w"> </span>0x00000000<span class="w"> </span>0x00000000<span class="w"> </span>0x00000000 +0x555555559180<span class="w"> </span><userid+64>:<span class="w"> </span>0x00000000<span class="w"> </span>0x00000000<span class="w"> </span>0x00000000<span class="w"> </span>0x00000000 +0x555555559190<span class="w"> </span><userid+80>:<span class="w"> </span>0x00000000<span class="w"> </span>0x00000000 +<span class="o">(</span>gdb<span class="o">)</span><span class="w"> </span> </code></pre> </div> <p>It appears that this is a linked list. With roughly the following structure:</p> <div class="codehilite"> -<pre><span></span><code><span class="k">struct</span><span class="w"> </span><span class="nc">node</span><span class="w"> </span><span class="p">{</span><span class="w"></span> -<span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">value</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">index</span><span class="p">;</span><span class="w"></span> -<span class="w"> </span><span class="k">struct</span><span class="w"> </span><span class="nc">node</span><span class="w"> </span><span class="o">*</span><span class="n">next</span><span class="p">;</span><span class="w"></span> -<span class="p">};</span><span class="w"></span> +<pre><span></span><code><span class="k">struct</span><span class="w"> </span><span class="nc">node</span><span class="w"> </span><span class="p">{</span> +<span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">value</span><span class="p">;</span> +<span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">index</span><span class="p">;</span> +<span class="w"> </span><span class="k">struct</span><span class="w"> </span><span class="nc">node</span><span class="w"> </span><span class="o">*</span><span class="n">next</span><span class="p">;</span> +<span class="p">};</span> </code></pre> </div> |